Структура языка программирования javascript

Структура JavaScript

В окружении браузера JavaScript структурно состоит из трех частей:

    Ядро (также известно как ECMAScript) является основой для функционирования остальных частей. В ядре реализуется синтаксис языка т.е. определяются ключевые и зарезервированные слова, условные конструкции, циклы, объекты и т.д. Ядро само по себе не имеет средств для вывода информации.

//Данный пример ничего не выводит так как в нем используются только возможности ядра //Создаем массив var var1=new Array("Машина", "Трактор"); //Создаем функцию, которая складывает переданные значения и возвращает результат function sum(a,b) < return a+b; >//Вызовем функцию и запишем результат в переменную c c=function(4,10);

Обратите внимание: ядро может использоваться в средах отличных от окружения браузера. К примеру оно используется в OpenOffice.org, Adobe Reader, Adobe Flash.

Обратите внимание: в предыдущих главах учебника в основном было рассмотрено именно ядро JavaScript. Остальные части будут рассматриваться далее в этом и в HTML DOM учебнике.

  

После нажатия на кнопку ниже будет отрыто новое окно браузера:

function winop()
   function change() 

После нажатия на кнопку ниже содержимое абзаца изменится на 'Данный текст выведен с помощью JavaScript'.

Это абзац содержащий обычный текст. Это абзац содержащий обычный текст.

Wisdomweb.ru © 2023.
Все права защищены. Любое использование материалов данного сайта без разрешения администрации запрещено.
Онлайн учебники по HTML, HTML5, CSS, JavaScript, AJAX, HDOM, jQuery.

Читайте также:  Выпуклая функция нелинейного программирования

Источник

Code Structure Of JavaScript | Fundamentals of JavaScript Programming Language | Part — 1

Code Structure Of JavaScript | Fundamentals of JavaScript Programming Language | JavaScript Tutorial | Part — 1

What is JavaScript Programming Language?

JavaScript is among the most powerful and flexible programming languages that allows you to implement complex features on a website, such as dynamic elements or interactivity which is used by several websites for scripting the webpages and It is designed for creating network-centric applications.

Code Structure Of JavaScript (js) :

Writing well-structured code takes proper thinking, understanding of design patterns, and experience.

  • JavaScript Statements
  • JavaScript Semicolons
  • JavaScript Whitespaces
  • JavaScript Parenthesis
  • JavaScript Identifiers
  • JavaScript Indentation
  • JavaScript Reserved Keyword
  • JavaScript Case Sensitive
  • JavaScript Comments
  • JavaScript Camel Case

Here is a list of some of the fundamentals of JavaScript that you will learn about in next tutorial of Part — 2 :

  • JavaScript Syntax
  • JavaScript Values
  • JavaScript Literals
  • JavaScript Expression
  • JavaScript Variables
  • JavaScript Operators
  • JavaScript Character Set
  • JavaScript Data Types
  • JavaScript Code Blocks
  • JavaScript Line Length and Line Breaks

1. Statements in JavaScript (js) :

JavaScript is made up of a series of statements and semi-colons and a JavaScript program is a list of programming statements. JavaScript statements are the commands to tell the browser to what action to perform which are used to perform different actions based on different conditions.

A statement can set a variable equal to a value. A statement can also be a function call, i.e. document.write(). Statements define what the script will do and how it will be done.

Types of Statements in JavaScript (js):

We will provide a brief overview of each of the categories and cover them in greater detail later in the tutorial. There are five types of statements in javascript (js) :

  1. Conditional Statements
  2. Loop Statements
  3. Object Manipulation Statements
  4. Comment Statements
  5. Exception Handling Statements
let numOne, numTwo, sum; // Statement 1 numOne = 5; // Statement 2 numTwo = 6; // Statement 3 sum = numOne + numTwo; // Statement 4

2. Semicolons (;) in JavaScript (js):

Semicolons (;) separate JavaScript statements which are the equivalent of a full stop and it is used to terminate a statement.

Читайте также:  Объектно ориентированное программирование ява

Semi-colons are not compulsory because t he JavaScript or js parser will automatically add a semicolon during the parsing of the source code but using semicolons are highly recommended. Semicolons are used at end of the statements. When separated by semicolons, multiple statements on one line are allowed.

let a, b, c; a = 5; b = 6; c = a + b;
// when multiple statements in one line

3. Whitespace in JavaScript (js):

A whitespace character is an empty space (without any visual representation) on screen. Whitespace in JavaScript consists of spaces, tabs, and newlines (pressing ENTER on the keyboard).

JavaScript ignores multiple spaces and free to format and indent programs in a neat and consistent way that makes the code easy to read and understand.

let person = "Best JavaScript Tutorials"; let person="Best JavaScript Tutorials";

4. Parenthesis in JavaScript (js):

In JavaScript we only write a value in the parentheses if we need to process that value and it is used for grouping expressions. For keywords such as if, switch, and for, spaces are usually added before and after the parentheses.

// An example of if statement syntax if () < >// Check math equation and print a string to the console if (4 < 5) < console.log("4 is less than 5."); >// An example of for loop syntax for () < >// Iterate 10 times, printing out each iteration number to the console for (let i = 0; i

5. Identifiers in JavaScript (js):

Identifier is a sequence of characters; which help us to identify specific part of a program and The name of a variable, function, or property is known as an identifier in JavaScript.

Читайте также:  Особенности программирования плк стандарт мэк 61131

Источник

Оцените статью