On this page
- 1 JavaScript: Getting started
- 2 JavaScript: Getting started
- 2.1 Tools For JavaScript Programming
- 2.2 Display output in JavaScript
- 2.3 Getting an element in Javascript:
- 2.4 Creating things in the documents
- 2.5 Example: Multidimensional Array
- 2.6 Object.keys, values, entries
- 2.6.0.1 Introduction to the DOM
- 2.6.0.2 How to apply CSS to iframe?
- 2.6.0.3 JavaScript Map, Reduce, and Filter
- 2.6.0.4 JavaScript Concepts Everyone Should Learn!
- 2.6.0.5 JavaScript: localStorage and sessionStorage
- 2.6.0.6 JavaScript: Array functions/methods
- 2.6.0.7 JavaScript: Array map() Method
- 2.6.0.8 Promise in JavaScript with example
- 2.6.0.9 JavaScript: FormData
- 2.6.0.10 JavaScript: How ES6 Arrow Function Can Help You
- 2.6.0.11 ES6: Spread operator
- 2.6.0.12 ES6: Spread syntax
- 2.6.0.13 ES6: Introduction
- 2.6.0.14 JavaScript: Scope and the Variable this
- 2.6.0.15 JavaScript: Get Element
- 2.6.0.16 JavaScript: JSON (JavaScript Object Notation)
- 2.6.0.17 JavaScript: Application programming interface (API)
- 2.6.0.18 Javascript : Date & Time Program
- 2.6.0.19 JavaScript: What is AJAX?
JavaScript: Getting started
JavaScript: Getting started
JavaScript is used to create client-side dynamic pages. JavaScript is an object-based scripting language which is lightweight and cross-platform.
Javascript First Program:
console.log("Welcome to Stately World");
On this page
Tools For JavaScript Programming
There are some tools including frameworks, debuggers, text editors, etc. that will help you code efficiently using JavaScript.
Text Editors
You can use Sublime Text, Notpad++, Visual Code, etc as a text editor.
Browser
You can use any browser for Javascript program. I am listing some browser name below.
Display output in JavaScript
JavaScript can “display” data in different ways:
console.log('Hello World');
document.write()
window.alert()
Getting an element in Javascript:
* getElementByID() * getElementsByClassName() * getElementsByTagName() * querySelector() + querySelectorAll()
Creating things in the documents
* createElement() * createAttribute()
Example: Multidimensional Array
var activities = [ ['Work', 9], ['Eat', 2], ['Commute', 2], ['Play Game', 2], ['Sleep', 7] ]; activities.push(['Study',2]); for (var i = 0; i < activities.length; i++) { console.log(i); var percentage = ((activities[i][1] / 24) * 100).toFixed(); activities[i][2] = percentage + '%'; } console.log(activities.join('\n')); // loop the outer array for (var i = 0; i < activities.length; i++) { // get the size of the inner array var innerArrayLength = activities[i].length; // loop the inner array for (var j = 0; j < innerArrayLength; j++) { console.log('[' + i + ',' + j + '] = ' + activities[i][j]); } }
Object.keys, values, entries
For plain objects, the following methods are available:
Object.keys(obj) – returns an array of keys.
Object.values(obj) – returns an array of values.
Object.entries(obj) – returns an array of [key, value] pairs.