~3 min read • Updated Oct 14, 2025
Introduction
The best way to master JavaScript is to start coding. But to do that effectively, you need to understand how the language works. This article offers a high-level overview of key JS concepts to help you build confidence and prepare for deeper learning. Take your time with each section, especially if you’re new to programming.
Each File Is a Program
JavaScript treats each standalone file (typically ending in .js) as a separate program. If one file fails during parsing or execution, it doesn’t necessarily stop other files from running. However, if your application depends on multiple files, a failure in one may cause partial functionality.
Files interact through the global scope, sharing state and functions. Since ES6, JS also supports modules, which are file-based and imported using import statements or <script type="module"> tags. Modules are treated as separate programs but can interact at runtime.
Note: Build tools like Webpack often combine multiple files into one. In that case, JS treats the combined file as a single program.
Values in JavaScript
Values are the building blocks of JS programs. They represent state and come in two categories: primitives and objects.
Primitive Values
- Strings: Ordered character sequences. Use
"or'for basic strings, and`(backticks) for interpolation:let firstName = "Kyle"; console.log(`My name is ${firstName}`); - Numbers: Used for math or indexing. Prefer
Math.PIover hardcoded values like3.141592. Usebigintfor very large numbers. - Booleans:
trueorfalsefor logic. Example:while (false) { console.log("This won't run."); } - null and undefined: Represent absence of value. Use
undefinedas the default empty value:while (value != undefined) { console.log("Still got something!"); } - Symbols: Unique keys for object properties, mostly used in libraries:
hitchhikersGuide[Symbol("meaning of life")]; // 42
Objects and Arrays
- Arrays: Ordered lists with numeric indices:
let names = ["Frank", "Kyle", "Peter", "Susan"]; console.log(names.length); // 4 console.log(names[1]); // Kyle - Objects: Unordered collections with string keys:
let name = { first: "Kyle", last: "Simpson", age: 39, specialties: ["JS", "Table Tennis"] }; console.log(`My name is ${name.first}`);
Note: Functions and arrays are special types of objects. More on that later.
Determining Value Types
Use typeof to check a value’s type:
typeof 42; // "number"
typeof "abc"; // "string"
typeof true; // "boolean"
typeof undefined; // "undefined"
typeof null; // "object" -- known bug!
typeof { a: 1 }; // "object"
typeof [1, 2, 3]; // "object"
typeof function hello() {}; // "function"Warning: typeof null returns "object" due to a legacy bug. Arrays also return "object", not a distinct "array" type.
Type conversion (coercion) and the difference between value and reference behavior are covered later in the book.
Conclusion
This survey introduces the foundational concepts of JavaScript: how files behave, what values are, and how to identify types. These ideas will be expanded in future chapters. For now, practice writing code, explore examples, and build your confidence step by step.
Written & researched by Dr. Shahin Siami