101.school
CoursesAbout
Search...⌘K
Generate a course with AI...

    JavaScript 101

    Receive aemail containing the next unit.
    • Introduction to JavaScript
      • 1.1What is JavaScript?
      • 1.2Setting up your environment
      • 1.3Basic syntax and variables
    • Data Types and Variables
      • 2.1Understanding data types
      • 2.2Variables and constants
      • 2.3Operators
    • Control Structures
      • 3.1Conditional statements
      • 3.2Loops
      • 3.3Error handling
    • Functions
      • 4.1Defining functions
      • 4.2Function expressions
      • 4.3Arrow functions
    • Objects and Arrays
      • 5.1Understanding objects
      • 5.2Understanding arrays
      • 5.3Array methods
    • Document Object Model (DOM)
      • 6.1What is the DOM?
      • 6.2Selecting and manipulating elements
      • 6.3Event handling
    • Asynchronous JavaScript
      • 7.1Callbacks
      • 7.2Promises
      • 7.3Async/Await
    • API Interaction
      • 8.1What is an API?
      • 8.2Fetch API
      • 8.3Working with JSON
    • Debugging
      • 9.1Console methods
      • 9.2Debugging tools
      • 9.3Common JavaScript errors
    • JavaScript Libraries
      • 10.1Introduction to libraries
      • 10.2Using jQuery
      • 10.3Using lodash
    • JavaScript Frameworks
      • 11.1Introduction to frameworks
      • 11.2Using React
      • 11.3Using Vue.js
    • Testing and Deployment
      • 12.1Writing tests with Jest
      • 12.2Deployment with Netlify
      • 12.3Continuous integration
    • Final Project
      • 13.1Project proposal
      • 13.2Project development
      • 13.3Project presentation

    Introduction to JavaScript

    Basic Syntax and Variables in JavaScript

    high-level programming language

    High-level programming language.

    In this unit, we will delve into the basic syntax rules of JavaScript and learn about variables.

    Basic Syntax Rules in JavaScript

    JavaScript syntax refers to the set of rules that define how a JavaScript program should be written and structured. Here are some basic rules:

    • Case Sensitivity: JavaScript is case-sensitive. This means myVariable and myvariable are two different variables.
    • Statements: JavaScript statements are commands that tell the browser what to do. They are often ended with a semicolon (;).
    • Whitespace: JavaScript ignores multiple spaces. You can add white space in your script to make it more readable.
    • Comments: Comments are used to explain the code and they are ignored by the browser. Single-line comments start with // and multi-line comments start with /* and end with */.

    Introduction to Variables

    Variables are fundamental to all programming languages. They are used to store data values. In JavaScript, we declare variables using the var, let, or const keywords.

    • var: This keyword is used to declare a variable. It can be reassigned and used throughout your whole program.
    • let: This keyword is also used to declare a variable, but the variable can only be used in the block of code in which it is defined.
    • const: This keyword is used to declare a variable that cannot be reassigned. It is a constant, as the name suggests.

    Here is an example of how to declare and assign variables:

    var name = 'John'; let age = 30; const pi = 3.14;

    In the above example, name is a variable declared with var and assigned the string 'John'. age is a variable declared with let and assigned the number 30. pi is a constant declared with const and assigned the value 3.14.

    Naming Conventions for Variables

    When naming your variables, it's important to follow certain conventions:

    • Variable names should be descriptive and reflect the data they hold.
    • They cannot start with a number.
    • They can contain letters, numbers, underscores, and dollar signs.
    • They cannot contain spaces or special characters.
    • JavaScript uses camel case for multi-word variable names (e.g., myVariableName).

    Understanding the basic syntax and variables is crucial in learning JavaScript as it forms the foundation for more complex concepts. In the next unit, we will explore data types and how they are used in JavaScript.

    Test me
    Practical exercise
    Further reading

    Buenos dias, any questions for me?

    Sign in to chat
    Next up: Understanding data types