Concept

JavaScript syntax

Summary
The syntax of JavaScript is the set of rules that define a correctly structured JavaScript program. The examples below make use of the log function of the console object present in most browsers for standard text output. The JavaScript standard library lacks an official standard text output function (with the exception of document.write). Given that JavaScript is mainly used for client-side scripting within modern web browsers, and that almost all Web browsers provide the alert function, alert can also be used, but is not commonly used. Brendan Eich summarized the ancestry of the syntax in the first paragraph of the JavaScript 1.1 specification as follows: JavaScript borrows most of its syntax from Java, but also inherits from Awk and Perl, with some indirect influence from Self in its object prototype system. JavaScript is case sensitive. It is common to start the name of a constructor with a capitalised letter, and the name of a function or variable with a lower-case letter. Example: var a = 5; console.log(a); // 5 console.log(A); // throws a ReferenceError: A is not defined Unlike in C, whitespace in JavaScript source can directly impact semantics. Semicolons end statements in JavaScript. Because of automatic semicolon insertion (ASI), some statements that are well formed when a newline is parsed will be considered complete, as if a semicolon were inserted just prior to the newline. Some authorities advise supplying statement-terminating semicolons explicitly, because it may lessen unintended effects of the automatic semicolon insertion. There are two issues: five tokens can either begin a statement or be the extension of a complete statement; and five restricted productions, where line breaks are not allowed in certain positions, potentially yielding incorrect parsing. The five problematic tokens are the open parenthesis "(", open bracket "[", slash "/", plus "+", and minus "-". Of these, the open parenthesis is common in the immediately invoked function expression pattern, and open bracket occurs sometimes, while others are quite rare.
About this result
This page is automatically generated and may contain information that is not correct, complete, up-to-date, or relevant to your search query. The same applies to every other page on this website. Please make sure to verify the information with EPFL's official sources.
Related courses (5)
CS-320: Computer language processing
We teach the fundamental aspects of analyzing and interpreting computer languages, including the techniques to build compilers. You will build a working compiler from an elegant functional language in
CS-108: Practice of object-oriented programming
Les étudiants perfectionnent leurs connaissances en Java et les mettent en pratique en réalisant un projet de taille conséquente. Ils apprennent à utiliser et à mettre en œuvre les principaux types de
CS-550: Formal verification
We introduce formal verification as an approach for developing highly reliable systems. Formal verification finds proofs that computer systems work under all relevant scenarios. We will learn how to u
Show more
Related lectures (31)
Data Representation in C++
Covers the basics of C++ programming, memory organization, and the development cycle, emphasizing the importance of initializing variables and common errors.
Vector Toolbox: Path, Methods
Explores the practical component of C++ programming, focusing on the vector toolbox and differences between arrays 'at the C' and arrays with several indexes in memory.
Closure Conversion and Dataflow Analysis
Explores closure conversion, function hoisting, and dataflow analysis for program optimization.
Show more
Related publications (13)

Scala 3 syntax rewriting

Mark Tropin

We present syntax rewriting rules that translate Scala 2 code into Scala 3. Two major syntactic changes are introduced: new control structure syntax and significant indentation. We describe the design and the implementation of these rules and evaluate thei ...
2024

The Jazz Harmony Treebank

Martin Alois Rohrmeier, Daniel Harasim, Christoph Finkensiep, Petter Harald Ericson

Grammatical models which represent the hierarchical structure of chord sequences have proven very useful in recent analyses of Jazz harmony. A critical resource for building and evaluating such models is a ground-truth database of syntax trees that encode ...
ISMIR2020

CoWriting Kazakh: Learning a New Script with a Robot

Pierre Dillenbourg, Thibault Lucien Christian Asselborn, Wafa Monia Benkaouar Johal

In the Republic of Kazakhstan, the transition from Cyrillic to Latin alphabet raises challenges to training an entire population in writing the new script. This paper presents a CoWriting Kazakh system, an extension of the existing CoWriter system, aiming ...
Association for Computing Machinery2020
Show more
Related concepts (7)
Comment (computer programming)
In computer programming, a comment is a programmer-readable explanation or annotation in the source code of a computer program. They are added with the purpose of making the source code easier for humans to understand, and are generally ignored by compilers and interpreters. The syntax of comments in various programming languages varies considerably. Comments are sometimes also processed in various ways to generate documentation external to the source code itself by documentation generators, or used for integration with source code management systems and other kinds of external programming tools.
Comparison of programming languages (syntax)
This comparison of programming languages compares the features of language syntax (format) for over 50 computer programming languages. Programming language expressions can be broadly classified into four syntax structures: prefix notation Lisp (* (+ 2 3) (expt 4 5)) infix notation Fortran (2 + 3) * (4 ** 5) suffix, postfix, or Reverse Polish notation Forth 2 3 + 4 5 ** * math-like notation TUTOR (2 + 3)(45) $$ note implicit multiply operator When a programming languages has statements, they typically have conventions for: statement separators; statement terminators; and line continuation A statement separator demarcates the boundary between two separate statements.
JSON
JSON (JavaScript Object Notation, pronounced ˈdʒeɪsən; also ˈdʒeɪˌsɒn) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other serializable values). It is a common data format with diverse uses in electronic data interchange, including that of web applications with servers. JSON is a language-independent data format. It was derived from JavaScript, but many modern programming languages include code to generate and parse JSON-format data.
Show more