{"id":543,"date":"2025-05-19T11:04:22","date_gmt":"2025-05-19T11:04:22","guid":{"rendered":"https:\/\/buhave.com\/courses\/?p=543"},"modified":"2026-06-06T12:59:23","modified_gmt":"2026-06-06T12:59:23","slug":"basics-and-syntax","status":"publish","type":"post","link":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/","title":{"rendered":"Basics and Syntax"},"content":{"rendered":"<h2>Variables (let, const, var)<\/h2>\n<h3>1. What Are Variables?<\/h3>\n<p>Variables store data values that can be used and manipulated in your code.<\/p>\n<p style=\"text-align: center\"><em>let name = &#8220;Alice&#8221;;<\/em><br \/>\n<em>const age = 30;<\/em><br \/>\n<em>var city = &#8220;Paris&#8221;;<\/em><\/p>\n<h3>2. let \u2013 Block-scoped, Reassignable<\/h3>\n<p>Introduced in ES6 (2015), let is the go-to for variables that can change. For scope rules and modern variable practices, see the <a href=\"https:\/\/buhave.com\/courses\/java-script\/functions-and-scope\/\" title=\"Functions and Scope\">Functions and Scope<\/a> lesson.<\/p>\n<p style=\"text-align: center\"><em>let counter = 1;<\/em><br \/>\n<em>counter = 2; \/\/ reassigning is allowed<\/em><\/p>\n<p><strong>Characteristics:<\/strong><\/p>\n<ul>\n<li>Block-scoped (confined to {}).<\/li>\n<li>Can be updated, but not re-declared in the same scope.<\/li>\n<li>Does not hoist the same way var does (it has a &#8220;temporal dead zone&#8221;).<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>{<\/em><br \/>\n<em>let x = 10;<\/em><br \/>\n<em>}<\/em><br \/>\n<em>\/\/ console.log(x); ReferenceError: x is not defined<\/em><\/p>\n<h3>3. const \u2013 Block-scoped, Not Reassignable<\/h3>\n<p>Used for constants \u2013 values that shouldn\u2019t change.<\/p>\n<p style=\"text-align: center\"><em>const pi = 3.14;<\/em><br \/>\n<em>\/\/ pi = 3.14159 Error: Assignment to constant variable<\/em><\/p>\n<p><strong>Characteristics:<\/strong><\/p>\n<ul>\n<li>Also block-scoped.<\/li>\n<li>Must be initialized when declared.<\/li>\n<li>You can\u2019t reassign, but if the value is an object or array, its contents can be changed.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>const person = { name: &#8220;Alice&#8221; };<\/em><br \/>\n<em>person.name = &#8220;Bob&#8221;; \/\/ allowed<\/em><\/p>\n<p>For examples of how const interacts with objects, see the <a href=\"https:\/\/buhave.com\/courses\/java-script\/arrays-and-objects\/\" title=\"Arrays and Objects\">Arrays and Objects<\/a> lesson.<\/p>\n<h3>4. var \u2013 Function-scoped, Legacy<\/h3>\n<p>Old way (pre-ES6) of declaring variables.<\/p>\n<p style=\"text-align: center\"><em>var color = &#8220;blue&#8221;;<\/em><br \/>\n<em>color = &#8220;red&#8221;; \/\/<\/em><\/p>\n<p><strong>Characteristics:<\/strong><\/p>\n<ul>\n<li>Function-scoped, not block-scoped.<\/li>\n<li>Can be re-declared and updated.<\/li>\n<li>Hoisted to the top of its function \u2014 initialized as undefined.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>console.log(a); \/\/ undefined<\/em><br \/>\n<em>var a = 5;<\/em><\/p>\n<h3>5. Comparison Table<\/h3>\n<table>\n<thead>\n<tr>\n<th>Feature<\/th>\n<th>var<\/th>\n<th>let<\/th>\n<th>const<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>Scope<\/td>\n<td>Function<\/td>\n<td>Block<\/td>\n<td>Block<\/td>\n<\/tr>\n<tr>\n<td>Hoisting<\/td>\n<td>Yes (initialized to undefined)<\/td>\n<td>Yes (in TDZ)<\/td>\n<td>Yes (in TDZ)<\/td>\n<\/tr>\n<tr>\n<td>Reassignable<\/td>\n<td class=\"check\">yes<\/td>\n<td class=\"check\">yes<\/td>\n<td class=\"cross\">no<\/td>\n<\/tr>\n<tr>\n<td>Redeclarable<\/td>\n<td class=\"check\">yes<\/td>\n<td class=\"cross\">no<\/td>\n<td class=\"cross\">no<\/td>\n<\/tr>\n<tr>\n<td>Use Case<\/td>\n<td>Legacy code<\/td>\n<td>Mutable variables<\/td>\n<td>Immutable bindings<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Best Practices:<\/strong><\/p>\n<ul>\n<li>Use <a href=\"https:\/\/buhave.com\/courses\/java-script\/introduction-to-javascript\/\" title=\"Introduction to JavaScript\">let<\/a> when the value will change.<\/li>\n<li>Use <a href=\"https:\/\/buhave.com\/courses\/java-script\/introduction-to-javascript\/\" title=\"Introduction to JavaScript\">const<\/a> by default \u2014 only switch to <a href=\"https:\/\/buhave.com\/courses\/java-script\/introduction-to-javascript\/\" title=\"Introduction to JavaScript\">let<\/a> if needed.<\/li>\n<li>Avoid <a href=\"https:\/\/buhave.com\/courses\/java-script\/introduction-to-javascript\/\" title=\"Introduction to JavaScript\">var<\/a> unless working with legacy code.<\/li>\n<\/ul>\n<h2>Data types (Number, String, Boolean, Null, Undefined, Symbol)<\/h2>\n<h3>1. Primitive Data Types in JavaScript<\/h3>\n<p><strong>JavaScript has 7 primitive types (6 main ones + BigInt added in ES2020):<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>Type<\/th>\n<th>Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"type-name\">Number<\/td>\n<td>Numeric values (integer or float)<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">String<\/td>\n<td>Text values<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Boolean<\/td>\n<td>true or false<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Null<\/td>\n<td>Intentional absence of value<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Undefined<\/td>\n<td>Declared but not assigned<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Symbol<\/td>\n<td>Unique and immutable identifier (ES6)<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">BigInt<\/td>\n<td>For very large integers (optional\/advanced)<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>2. Number<\/h3>\n<p>Represents both integers and floating-point numbers.<\/p>\n<p style=\"text-align: center\"><em>let age = 30;<\/em><br \/>\n<em>let price = 19.99;<\/em><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>All numbers are 64-bit floating point under the hood.<\/li>\n<\/ul>\n<p><strong>Special values:<\/strong><\/p>\n<ul>\n<li>Infinity, -Infinity, NaN (Not a Number)<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>console.log(1 \/ 0); \/\/ Infinity<\/em><br \/>\n<em>console.log(&#8220;a&#8221; \/ 2); \/\/ NaN<\/em><\/p>\n<h3>3. String<\/h3>\n<p>Represents text data.<\/p>\n<p style=\"text-align: center\"><em>let name = &#8220;Alice&#8221;;<\/em><br \/>\n<em>let greeting = &#8216;Hello&#8217;;<\/em><br \/>\n<em>let phrase = `Hi, ${name}`;<\/em><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>Can be declared with single, double, or backticks.<\/li>\n<li>Backticks (`) allow template literals and interpolation.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>let result = `2 + 2 = ${2 + 2}`; \/\/ &#8220;2 + 2 = 4&#8221;<\/em><\/p>\n<h3>4. Boolean<\/h3>\n<p>Represents a true\/false value.<\/p>\n<p style=\"text-align: center\"><em>let isActive = true;<\/em><br \/>\n<em>let isLoggedIn = false;<\/em><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>Used in conditionals, logic, and comparisons.<\/li>\n<li>Falsy values include: false, 0, &#8220;&#8221;, null, undefined, NaN<\/li>\n<\/ul>\n<h3>5. Null<\/h3>\n<p>Represents intentional absence of any value.<\/p>\n<p style=\"text-align: center\"><em>let score = null;<\/em><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>Often used to reset or clear a variable.<\/li>\n<li>typeof null is &#8220;object&#8221; \u2014 a quirk in JavaScript.<\/li>\n<\/ul>\n<h3>6. Undefined<\/h3>\n<p>A variable that\u2019s declared but not assigned.<\/p>\n<p style=\"text-align: center\"><em>let x;<\/em><br \/>\n<em>console.log(x); \/\/ undefined<\/em><\/p>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>Also returned by functions that don\u2019t explicitly return anything.<\/li>\n<li>JavaScript uses it to signal &#8220;missing&#8221; or &#8220;uninitialized&#8221;.<\/li>\n<\/ul>\n<h3>7. Symbol (ES6+)<\/h3>\n<p>Represents a unique, immutable identifier.<\/p>\n<p style=\"text-align: center\"><em>let id = Symbol(&#8220;userID&#8221;);<\/em><br \/>\n<em>let id2 = Symbol(&#8220;userID&#8221;);<\/em><br \/>\n<em>console.log(id === id2); \/\/ false<\/em><\/p>\n<p><strong>Use Case:<\/strong><\/p>\n<ul>\n<li>Creating unique property keys in objects to avoid name collisions.<\/li>\n<\/ul>\n<p><strong>Bonus: BigInt (ES2020+)<\/strong><\/p>\n<p style=\"text-align: center\"><em>For working with very large integers beyond Number.MAX_SAFE_INTEGER.<\/em><\/p>\n<p style=\"text-align: center\"><em>let big = 1234567890123456789012345678901234567890n;<\/em><\/p>\n<p><strong>Type Summary Table:<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>Type<\/th>\n<th>Example<\/th>\n<th>typeof result<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"type-name\">Number<\/td>\n<td class=\"example\">42, 3.14<\/td>\n<td class=\"typeof-result\">&#8220;number&#8221;<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">String<\/td>\n<td class=\"example\">&#8220;hello&#8221;, &#8216;world&#8217;<\/td>\n<td class=\"typeof-result\">&#8220;string&#8221;<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Boolean<\/td>\n<td class=\"example\">true, false<\/td>\n<td class=\"typeof-result\">&#8220;boolean&#8221;<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Null<\/td>\n<td class=\"example\">null<\/td>\n<td class=\"typeof-result\">&#8220;object&#8221; <span class=\"note\">(historical quirk)<\/span><\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Undefined<\/td>\n<td class=\"example\">undefined<\/td>\n<td class=\"typeof-result\">&#8220;undefined&#8221;<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">Symbol<\/td>\n<td class=\"example\">Symbol(&#8220;id&#8221;)<\/td>\n<td class=\"typeof-result\">&#8220;symbol&#8221;<\/td>\n<\/tr>\n<tr>\n<td class=\"type-name\">BigInt<\/td>\n<td class=\"example\">123n<\/td>\n<td class=\"typeof-result\">&#8220;bigint&#8221;<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2>Operators: arithmetic, comparison, logical<\/h2>\n<h3>1. Arithmetic Operators<\/h3>\n<p>Used to perform mathematical calculations.<\/p>\n<table>\n<thead>\n<tr>\n<th>Operator<\/th>\n<th>Description<\/th>\n<th>Example<\/th>\n<th>Result<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"operator\">+<\/td>\n<td>Addition<\/td>\n<td class=\"example\">5 + 2<\/td>\n<td class=\"result\">7<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&#8211;<\/td>\n<td>Subtraction<\/td>\n<td class=\"example\">5 &#8211; 2<\/td>\n<td class=\"result\">3<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">*<\/td>\n<td>Multiplication<\/td>\n<td class=\"example\">5 * 2<\/td>\n<td class=\"result\">10<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">\/<\/td>\n<td>Division<\/td>\n<td class=\"example\">5 \/ 2<\/td>\n<td class=\"result\">2.5<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">%<\/td>\n<td>Modulus (Remainder)<\/td>\n<td class=\"example\">5 % 2<\/td>\n<td class=\"result\">1<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">**<\/td>\n<td>Exponentiation<\/td>\n<td class=\"example\">5 ** 2<\/td>\n<td class=\"result\">25<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">++<\/td>\n<td>Increment<\/td>\n<td class=\"example\">let x = 1; x++<\/td>\n<td class=\"result\">2 <span class=\"note\">(x becomes 2)<\/span><\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&#8212;<\/td>\n<td>Decrement<\/td>\n<td class=\"example\">let x = 2; x&#8211;<\/td>\n<td class=\"result\">1 <span class=\"note\">(x becomes 1)<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Notes:<\/strong><\/p>\n<ul>\n<li>++ and &#8212; have prefix and postfix forms.<\/li>\n<\/ul>\n<p style=\"text-align: center\"><em>let a = 5;<\/em><br \/>\n<em>console.log(++a); \/\/ 6 (prefix: increment, then use)<\/em><br \/>\n<em>console.log(a++); \/\/ 6 (postfix: use, then increment)<\/em><\/p>\n<h3>2. Comparison Operators<\/h3>\n<p>Used to compare values; result is always true or false.<\/p>\n<table>\n<thead>\n<tr>\n<th>Operator<\/th>\n<th>Description<\/th>\n<th>Example<\/th>\n<th>Result<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"operator\">==<\/td>\n<td>Equal to (loose)<\/td>\n<td class=\"example\">5 == &#8220;5&#8221;<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">===<\/td>\n<td>Equal to (strict)<\/td>\n<td class=\"example\">5 === &#8220;5&#8221;<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">!=<\/td>\n<td>Not equal (loose)<\/td>\n<td class=\"example\">5 != &#8220;5&#8221;<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">!==<\/td>\n<td>Not equal (strict)<\/td>\n<td class=\"example\">5 !== &#8220;5&#8221;<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&gt;<\/td>\n<td>Greater than<\/td>\n<td class=\"example\">5 &gt; 2<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&lt;<\/td>\n<td>Less than<\/td>\n<td class=\"example\">5 &lt; 2<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&gt;=<\/td>\n<td>Greater than or equal to<\/td>\n<td class=\"example\">5 &gt;= 5<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">&lt;=<\/td>\n<td>Less than or equal to<\/td>\n<td class=\"example\">5 &lt;= 4<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Notes:<\/strong><\/p>\n<p>=== and !== are preferred to avoid type coercion issues.<\/p>\n<p style=\"text-align: center\"><em>0 == false \/\/ true<\/em><br \/>\n<em>0 === false \/\/ false<\/em><\/p>\n<h3>3. Logical Operators<\/h3>\n<p>Used for combining boolean expressions.<\/p>\n<table>\n<thead>\n<tr>\n<th>Operator<\/th>\n<th>Name<\/th>\n<th>Example<\/th>\n<th>Result<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"operator\">&amp;&amp;<\/td>\n<td>AND<\/td>\n<td class=\"example\">true &amp;&amp; false<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">||<\/td>\n<td>OR<\/td>\n<td class=\"example\">true || false<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"operator\">!<\/td>\n<td>NOT<\/td>\n<td class=\"example\">!true<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><strong>Truth Table for &amp;&amp; and ||:<\/strong><\/p>\n<table>\n<thead>\n<tr>\n<th>A<\/th>\n<th>B<\/th>\n<th class=\"operator\">A &amp;&amp; B (AND)<\/th>\n<th class=\"operator\">A || B (OR)<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td class=\"result-true\">true<\/td>\n<td class=\"result-true\">true<\/td>\n<td class=\"result-true\">true<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"result-true\">true<\/td>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-true\">true<\/td>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-true\">true<\/td>\n<\/tr>\n<tr>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-false\">false<\/td>\n<td class=\"result-false\">false<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p class=\"note\"><strong>Notes:<\/strong><\/p>\n<p class=\"note\">Logical operators return the last evaluated value, not just true or false.<\/p>\n<p style=\"text-align: center\"><em>let name = &#8220;&#8221;;<\/em><br \/>\n<em>let username = name || &#8220;Guest&#8221;; \/\/ &#8220;Guest&#8221; because &#8220;&#8221; is falsy<\/em><\/p>\n<p style=\"text-align: center\"><em>let isLoggedIn = true;<\/em><br \/>\n<em>isLoggedIn &amp;&amp; console.log(&#8220;Welcome!&#8221;); \/\/ Logs only if true<\/em><\/p>\n<p><strong>Bonus:<\/strong> Combined Example<\/p>\n<p style=\"text-align: center\"><em>let age = 20;<\/em><\/p>\n<p style=\"text-align: center\"><em>if (age &gt;= 18 &amp;&amp; age &lt; 65) {<\/em><br \/>\n<em>console.log(&#8220;Adult&#8221;);<\/em><br \/>\n<em>} else if (age &gt;= 65) {<\/em><br \/>\n<em>console.log(&#8220;Senior&#8221;);<\/em><br \/>\n<em>} else {<\/em><br \/>\n<em>console.log(&#8220;Minor&#8221;);<\/em><br \/>\n<em>}<\/em><\/p>\n<h2>String concatenation and template literals<\/h2>\n<h3>1. String Concatenation (Using + or +=)<\/h3>\n<p>This is the classic way of combining strings.<\/p>\n<p style=\"text-align: center\"><em>let firstName = &#8220;John&#8221;;<\/em><br \/>\n<em>let lastName = &#8220;Doe&#8221;;<\/em><br \/>\n<em>let fullName = firstName + &#8221; &#8221; + lastName;<\/em><br \/>\n<em>console.log(fullName); \/\/ &#8220;John Doe&#8221;<\/em><\/p>\n<p><strong>Concatenating Multiple Strings:<\/strong><\/p>\n<p style=\"text-align: center\"><em>let msg = &#8220;Hello, &#8221; + firstName + &#8220;! You have &#8221; + 3 + &#8221; new messages.&#8221;;<\/em><\/p>\n<ul>\n<li>Numbers are converted to strings automatically.<\/li>\n<li>Can get messy with many variables or dynamic content.<\/li>\n<\/ul>\n<p><strong>+= Operator:<\/strong><\/p>\n<p><strong>Used to append strings or accumulate values progressively.<\/strong><\/p>\n<p style=\"text-align: center\"><em>let s = &#8220;Hello&#8221;;<\/em><br \/>\n<em>s += &#8220; World&#8221;;<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Variables (let, const, var) 1. What Are Variables? Variables store data values that can be used and manipulated in your [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":544,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"site-sidebar-layout":"default","site-content-layout":"","ast-site-content-layout":"default","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","ast-disable-related-posts":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"categories":[13],"tags":[],"class_list":["post-543","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-java-script"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Basics and Syntax - Java Script Course<\/title>\n<meta name=\"description\" content=\"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Basics and Syntax - Java Script Course\" \/>\n<meta property=\"og:description\" content=\"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/\" \/>\n<meta property=\"og:site_name\" content=\"BUHAVE\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/BeYouHave\/\" \/>\n<meta property=\"article:author\" content=\"https:\/\/www.facebook.com\/naveedsafdarawan\/\" \/>\n<meta property=\"article:published_time\" content=\"2025-05-19T11:04:22+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-06T12:59:23+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"Naveed Safdar\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Naveed Safdar\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"7 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/\"},\"author\":{\"name\":\"Naveed Safdar\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\"},\"headline\":\"Basics and Syntax\",\"datePublished\":\"2025-05-19T11:04:22+00:00\",\"dateModified\":\"2026-06-06T12:59:23+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/\"},\"wordCount\":889,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Basics-and-Syntax.webp\",\"articleSection\":[\"Java Script Course\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/\",\"name\":\"Basics and Syntax - Java Script Course\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Basics-and-Syntax.webp\",\"datePublished\":\"2025-05-19T11:04:22+00:00\",\"dateModified\":\"2026-06-06T12:59:23+00:00\",\"description\":\"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#primaryimage\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Basics-and-Syntax.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/04\\\/Basics-and-Syntax.webp\",\"width\":1200,\"height\":628,\"caption\":\"Basics and Syntax\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/java-script\\\/basics-and-syntax\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Courses\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Script Course\",\"item\":\"https:\\\/\\\/buhave.com\\\/courses\\\/learn\\\/java-script\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Basics and Syntax\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#website\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"name\":\"BUHAVE\",\"description\":\"Courses - Learn Online for Free\",\"publisher\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/buhave.com\\\/courses\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#organization\",\"name\":\"BUHAVE\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"contentUrl\":\"https:\\\/\\\/buhave.com\\\/courses\\\/wp-content\\\/uploads\\\/2025\\\/03\\\/buhave-course.webp\",\"width\":375,\"height\":75,\"caption\":\"BUHAVE\"},\"image\":{\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/BeYouHave\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/buhave\",\"https:\\\/\\\/www.youtube.com\\\/@buhave\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/buhave.com\\\/courses\\\/#\\\/schema\\\/person\\\/04fe0254e118521c9fbb3da39de5acca\",\"name\":\"Naveed Safdar\",\"description\":\"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.\",\"sameAs\":[\"https:\\\/\\\/www.linkedin.com\\\/in\\\/naveedsafdar\\\/\",\"https:\\\/\\\/www.facebook.com\\\/naveedsafdarawan\\\/\",\"https:\\\/\\\/www.youtube.com\\\/@naveedsafdar\"],\"url\":\"https:\\\/\\\/buhave.com\\\/courses\\\/author\\\/naveed-safdar\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Basics and Syntax - Java Script Course","description":"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/","og_locale":"en_US","og_type":"article","og_title":"Basics and Syntax - Java Script Course","og_description":"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.","og_url":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/","og_site_name":"BUHAVE","article_publisher":"https:\/\/www.facebook.com\/BeYouHave\/","article_author":"https:\/\/www.facebook.com\/naveedsafdarawan\/","article_published_time":"2025-05-19T11:04:22+00:00","article_modified_time":"2026-06-06T12:59:23+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp","type":"image\/webp"}],"author":"Naveed Safdar","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Naveed Safdar","Est. reading time":"7 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#article","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/"},"author":{"name":"Naveed Safdar","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca"},"headline":"Basics and Syntax","datePublished":"2025-05-19T11:04:22+00:00","dateModified":"2026-06-06T12:59:23+00:00","mainEntityOfPage":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/"},"wordCount":889,"commentCount":0,"publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"image":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp","articleSection":["Java Script Course"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/","url":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/","name":"Basics and Syntax - Java Script Course","isPartOf":{"@id":"https:\/\/buhave.com\/courses\/#website"},"primaryImageOfPage":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#primaryimage"},"image":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#primaryimage"},"thumbnailUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp","datePublished":"2025-05-19T11:04:22+00:00","dateModified":"2026-06-06T12:59:23+00:00","description":"JavaScript basics and syntax provide the foundational rules and structure for writing and organizing code to create dynamic web behavior.","breadcrumb":{"@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#primaryimage","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/04\/Basics-and-Syntax.webp","width":1200,"height":628,"caption":"Basics and Syntax"},{"@type":"BreadcrumbList","@id":"https:\/\/buhave.com\/courses\/java-script\/basics-and-syntax\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Courses","item":"https:\/\/buhave.com\/courses\/"},{"@type":"ListItem","position":2,"name":"Java Script Course","item":"https:\/\/buhave.com\/courses\/learn\/java-script\/"},{"@type":"ListItem","position":3,"name":"Basics and Syntax"}]},{"@type":"WebSite","@id":"https:\/\/buhave.com\/courses\/#website","url":"https:\/\/buhave.com\/courses\/","name":"BUHAVE","description":"Courses - Learn Online for Free","publisher":{"@id":"https:\/\/buhave.com\/courses\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/buhave.com\/courses\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/buhave.com\/courses\/#organization","name":"BUHAVE","url":"https:\/\/buhave.com\/courses\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/","url":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","contentUrl":"https:\/\/buhave.com\/courses\/wp-content\/uploads\/2025\/03\/buhave-course.webp","width":375,"height":75,"caption":"BUHAVE"},"image":{"@id":"https:\/\/buhave.com\/courses\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/BeYouHave\/","https:\/\/www.linkedin.com\/company\/buhave","https:\/\/www.youtube.com\/@buhave"]},{"@type":"Person","@id":"https:\/\/buhave.com\/courses\/#\/schema\/person\/04fe0254e118521c9fbb3da39de5acca","name":"Naveed Safdar","description":"I\u2019m Naveed Safdar - SEO Manager with over 10 years of experience in SEO and Digital Marketing. I\u2019ve had the privilege of working with leading national and international companies including Grafdom, PakWheels, Systems Limited, Confiz, Educative, and Dubizzle Labs. My expertise spans technical SEO, content strategy, organic growth, and performance analytics - helping businesses improve visibility, traffic, and ROI.","sameAs":["https:\/\/www.linkedin.com\/in\/naveedsafdar\/","https:\/\/www.facebook.com\/naveedsafdarawan\/","https:\/\/www.youtube.com\/@naveedsafdar"],"url":"https:\/\/buhave.com\/courses\/author\/naveed-safdar\/"}]}},"_links":{"self":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/543","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/comments?post=543"}],"version-history":[{"count":3,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/543\/revisions"}],"predecessor-version":[{"id":1145,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/posts\/543\/revisions\/1145"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media\/544"}],"wp:attachment":[{"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/media?parent=543"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/categories?post=543"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/buhave.com\/courses\/wp-json\/wp\/v2\/tags?post=543"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}