GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — JavaScript Syntax - GeeksforGeeks JavaScript SyntaxLast Updated : 11 Jul, 2025 JavaScript syntax refers to the rules and conventions dictating how code is structured and arranged within the JavaScript programming language. This includes statements, expressions, variables, functions, operators, and control flow constructs. Syntax console.log("Basic Print method in JavaScript");JavaScript syntax refers to the set of rules that determines how JavaScript programs are constructed: // Variable declaration
let c, d, e;
// Assign value to the variable
c = 5;
// Computer value of variables
d = c;
e = c / d;JavaScript ValuesThere are two types of values defined in JavaScript Syntax:
These are the features of JavaScript which have some predefined syntax: Table of Content JavaScript LiteralsSyntax Rules for the JavaScript fixed values are:
Output 50 50.05 Geek Geeks JavaScript VariablesA JavaScript variable is the simple name of the storage location where data is stored. There are two types of variables in JavaScript which are listed below:
Example: This example shows the use of JavaScript variables.
Output: Apple
45
JavaScript OperatorsJavaScript operators are symbols that are used to compute the value or in other words, we can perform operations on operands. Arithmetic operators ( +, -, *, / ) are used to compute the value, and Assignment operators ( =, +=, %= ) are used to assign the values to variables. Example: This example shows the use of javascript operators.
Output 26 JavaScript ExpressionsJavascript Expression is the combination of values, operators, and variables. It is used to compute the values. Example: This example shows a JavaScript expression.
Output 10 50 JavaScript KeywordsThe keywords are the reserved words that have special meanings in JavaScript. // let is the keyword used to
// define the variable
let a, b;
// function is the keyword which tells
// the browser to create a function
function GFG(){};JavaScript CommentsThe comments are ignored by the JavaScript compiler. It increases the readability of code. It adds suggestions, Information, and warning of code. Anything written after double slashes // (single-line comment) or between /* and */ (multi-line comment) is treated as a comment and ignored by the JavaScript compiler. Example: This example shows the use of javascript comments.
Output 50 JavaScript Data TypesJavaScript provides different datatypes to hold different values on variables. JavaScript is a dynamic programming language, which means do not need to specify the type of variable. There are two types of data types in JavaScript.
// It store string data type
let txt = "GeeksforGeeks";
// It store integer data type
let a = 5;
let b = 5;
// It store Boolean data type
(a == b )
// To check Strictly (i.e. Whether the datatypes
// of both variables are same) === is used
(a === b)---> returns true to the console
// It store array data type
let places= ["GFG", "Computer", "Hello"];
// It store object data (objects are
// represented in the below way mainly)
let Student = {
firstName: "Johnny",
lastName: "Diaz",
age: 35,
mark: "blueEYE"
}JavaScript FunctionsJavaScript functions are the blocks of code used to perform some particular operations. JavaScript function is executed when something calls it. It calls many times so the function is reusable. Syntax: function functionName( par1, par2, ....., parn ) {
// Function code
} The JavaScript function can contain zero or more arguments. Example: This example shows the use of Javascript functions.
Output 45 JavaScript IdentifiersJavaScript Identifiers are names used to name variables and keywords and functions. A identifier must begin with:
Note: Numbers are not allowed as a first character in JavaScript Identifiers. JavaScript Case SensitiveJavaScript Identifiers are case-sensitive. Example: Both the variables firstName and firstname are different from each other.
Output Geek 100 JavaScript Camel CaseIn JavaScript Camel case is preferred to name a identifier. Example: let firstName
let lastNameJavaScript Character SetA unicode character set is used in JavaScript. A unicode covers the characters, punctuations and symbols. We have a complete article on character sets. Click here to read Charsets article. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |