What is javascript?
JavaScript (JS) is a lightweight interpreted or JIT-compiled programming language with first-class functions. While it is most well-known as the scripting language for Web pages, many non-browser environments also use it, such as Node.js, Apache CouchDB and Adobe Acrobat. JavaScript is a prototype-based, multi-paradigm, dynamic language, supporting object-oriented, imperative, and declarative (e.g. functional programming) styles.
Read more about JavaScript.
Javascript and Java
Do not confuse JavaScript with the Java programming language.
Both "Java" and "JavaScript" are trademarks or registered trademarks of Oracle in the U.S. and other countries. However, the two programming languages have very different syntax, semantics, and uses.
Javascript arrays
The JavaScript Array object is a global object that is used in the construction of arrays; which are high-level, list-like objects.
-
Create an Array
var fruits = ['Apple', 'Banana'];
console.log(fruits.length);
// 2
-
Access (index into) an Array item
var first = fruits[0];
// Apple
var last = fruits[fruits.length - 1];
// Banana
-
Loop over an Array
fruits.forEach(function(item, index, array) {
console.log(item, index);
});
// Apple 0
// Banana 1
-
Add to the end of an Array
var newLength = fruits.push('Orange');
// ["Apple", "Banana", "Orange"]
-
Remove from the end of an Array
var last = fruits.pop(); // remove Orange (from the end)
// ["Apple", "Banana"];
-
Remove from the front of an Array
var first = fruits.shift(); // remove Apple from the front
// ["Banana"];
-
Add to the front of an Array
var newLength = fruits.unshift('Strawberry') // add to the front
// ["Strawberry", "Banana"];
-
Find the index of an item in the Array
fruits.push('Mango');
// ["Strawberry", "Banana", "Mango"]
var pos = fruits.indexOf('Banana');
// 1
-
Remove an item by index position
var removedItem = fruits.splice(pos, 1); // this is how to remove an item
// ["Strawberry", "Mango"]
-
Copy an Array
var shallowCopy = fruits.slice(); // this is how to make a copy
// ["Strawberry", "Mango"]
Javascript first steps
Answers some fundamental questions such as "what is JavaScript?", "what does it look like?", and "what can it do?", along with discussing key JavaScript features such as variables, strings, numbers, and arrays.
read more about Javscript first steps
Introducing javascript objects
The object-oriented nature of JavaScript is important to understand if you want to go further with your knowledge of the language and write more efficient code, therefore we've provided this module to help you.
read more about javascript objects
Javascript guide
A much more detailed guide to the JavaScript language, aimed at those with previous programming experience either in JavaScript or another language.
read more about javascript guide
Client-side web APIs
When writing client-side JavaScript for web sites or applications, you won't go very far before you start to use APIs — interfaces for manipulating different aspects of the browser and operating system the site is running on, or even data from other web sites or services. In this module we will explore what APIs are, and how to use some of the most common APIs you'll come across often in your development work.
read more about Client-side web APIs
A re-introduction to javascript
An overview for those who think they know about JavaScript.
read more about re-introduction to javascript
Javascript data structures
Overview of available data structures in JavaScript.
read more about Javascript data structures
Equality comparisons and sameness
JavaScript provides three different value-comparison operations: strict equality using ===
, loose equality using ==
, and the Object.is()
method.
read more about Equality comparisons and sameness
Closures
A closure is the combination of a function and the lexical environment within which that function was declared.
read more about Closures
Full reference
the journey of javascript mastery starts with a simple hello world
read more about Javascript