When it is usedĪlongside the Equality operator, the negation operator tests whether twoįor "Not", the basic expression is true, but theĬomparison returns false because we negate it: This returns the logically opposite value of what it precedes. This performs a test to see if two values are equal. These do what you'd expect them to do in basic math.Īs you've seen already: this assigns a value to a variable. OperatorĪdd two numbers together or combine two strings. In the following table, you can see some of the simplest operators, along with some examples to try in the JavaScript console. CommentsĪn operator is a mathematical symbol that produces a result based on two values (or variables). If values couldn't change, then you couldn't do anything dynamic, like personalize a greeting message or change an image displayed in an image gallery. So why do we need variables? Variables are necessary to do anything interesting in programming. Let myVariable = document.querySelector('h1') Everything in JavaScript is an object and can be This is a structure that allows you to store multiple values in a single The words true andįalse are special keywords that don't need quote marks. Is a string, enclose it in single quote marks.
This is a sequence of text known as a string. Note that variables may hold values that have different data types: Variable Have fun! A Hello world! exampleĪfter assigning a value to a variable, you can change it later in the code: let myVariable = 'Bob' The section below introduces some aspects of the core language and offers an opportunity to play with a few browser API features too. You can learn more in MDN's JavaScript learning area, as well as in other parts of MDN. It's outside the scope of this article-as a light introduction to JavaScript-to present the details of how the core JavaScript language is different from the tools listed above.
JavaScript itself is relatively compact, yet very flexible. With more experience, you'll be able to create games, animated 2D and 3D graphics, comprehensive database-driven apps, and much more! JavaScript is versatile and beginner-friendly. It was invented by Brendan Eich (co-founder of the Mozilla project, the Mozilla Foundation, and the Mozilla Corporation). JavaScript is a powerful programming language that can add interactivity to a website.