Hosted by Dailymotion. For legal issues report at the Copyright Center, report us on DMC, or use the Instant Removal tool.
JavaScript Basics
Description
In this video we will discuss
1. Is JavaScript case sensitive
2. Comments in JavaScript
3. Data types in JavaScript
Is JavaScript case sensitive
Yes, JavaScript is case sensitive programming language. Variable names, keywords, methods, object properties and event handlers all are case sensitive.
Example 1 : alert() function name should be all small letters
alert("JavaScripts Basics Tutorial");
Example 2 : Alert() is not same as alert(). Throws Alert is not defined error. To see the error press F12 key.
Alert("JavaScripts Basics Tutorial");
Comments in JavaScript : There are 2 types of comments in JavaScript.
1) Single Line Comment
Example :
// This is a sinle line comment
2) Multi Line Comment
Example:
/* This is a
multi line
comment */
Data types in JavaScript
The following are the different data types in JavaScript
Numbers - 5, 5.234
Boolean - true / false
String - "MyString", 'MyString'
To create a variable in JavaScript use var keyword. Variable names are case sensitive.
In c# to create an integer variable we use int keyword
int X = 10;
to create a string variable we use string keyword
string str = "Hello"
With JavaScript we always use var keyword to create any type of variable. Based on the value assigned the type of the variable is inferred.
var a = 10;
var b = "MyString";
In C#, you cannot assign a string value to an integer variable
int X = 10;
X = "Hello"; // Compiler error
JavaScript is a dynamically typed language. This means JavaScript data types are converted automatically as needed during script execution. Notice that, in myVariable we are first storing a number and then a string later.
var myVariable = 100;
alert(myVariable);
myVariable = "Assigning a string value";
alert(myVariable);
When a + operator is used with 2 numbers, JavaScripts adds those numbers.
var a = 10;
var b = 20;
var c = a + b;
alert(c);
Output : 30
When a + operator is used with 2 strings, JavaScript concatenates those 2 strings
var a = "Hello "
var b = "JavaScript";
var c = a + b;
alert(c);
Output : Hello JavaScript
When a + operator is used with a string and a number, JavaScript converts the numeric value to a string and performs concatenation.
var a = "Number is : "
var b = 10;
var c = a + b;
alert(c);
Output : Number is 10
var a = "50"
var b = 10;
var c = a + b;
alert(c);
Output : 5010
But if you use a minus operator, numeric value is not converted to string
var a = "50"
var b = 10;
var c = a - b;
alert(c);
Output : 40
1. Is JavaScript case sensitive
2. Comments in JavaScript
3. Data types in JavaScript
Is JavaScript case sensitive
Yes, JavaScript is case sensitive programming language. Variable names, keywords, methods, object properties and event handlers all are case sensitive.
Example 1 : alert() function name should be all small letters
alert("JavaScripts Basics Tutorial");
Example 2 : Alert() is not same as alert(). Throws Alert is not defined error. To see the error press F12 key.
Alert("JavaScripts Basics Tutorial");
Comments in JavaScript : There are 2 types of comments in JavaScript.
1) Single Line Comment
Example :
// This is a sinle line comment
2) Multi Line Comment
Example:
/* This is a
multi line
comment */
Data types in JavaScript
The following are the different data types in JavaScript
Numbers - 5, 5.234
Boolean - true / false
String - "MyString", 'MyString'
To create a variable in JavaScript use var keyword. Variable names are case sensitive.
In c# to create an integer variable we use int keyword
int X = 10;
to create a string variable we use string keyword
string str = "Hello"
With JavaScript we always use var keyword to create any type of variable. Based on the value assigned the type of the variable is inferred.
var a = 10;
var b = "MyString";
In C#, you cannot assign a string value to an integer variable
int X = 10;
X = "Hello"; // Compiler error
JavaScript is a dynamically typed language. This means JavaScript data types are converted automatically as needed during script execution. Notice that, in myVariable we are first storing a number and then a string later.
var myVariable = 100;
alert(myVariable);
myVariable = "Assigning a string value";
alert(myVariable);
When a + operator is used with 2 numbers, JavaScripts adds those numbers.
var a = 10;
var b = 20;
var c = a + b;
alert(c);
Output : 30
When a + operator is used with 2 strings, JavaScript concatenates those 2 strings
var a = "Hello "
var b = "JavaScript";
var c = a + b;
alert(c);
Output : Hello JavaScript
When a + operator is used with a string and a number, JavaScript converts the numeric value to a string and performs concatenation.
var a = "Number is : "
var b = 10;
var c = a + b;
alert(c);
Output : Number is 10
var a = "50"
var b = 10;
var c = a + b;
alert(c);
Output : 5010
But if you use a minus operator, numeric value is not converted to string
var a = "50"
var b = 10;
var c = a - b;
alert(c);
Output : 40
More from User
07:58
JavaScript Basics
Kudvenkat
09:40
Where should the script tag be placed in html
Kudvenkat
06:30
Inline vs external javascript
Kudvenkat
06:02
Tools for learning JavaScript
Kudvenkat
04:15
How to debug javascript in visual studio
Kudvenkat
06:46
Disadvantages of JavaScript
Kudvenkat
Related Videos
29:58
JavaScript Basics in Hindi | JavaScript Tutorial in Hindi for Beginners | JavaScript Easy Part - 1
ADMEC MULTIMEDIA INSTITUTE
06:18
Javascript Basics What is a Programming Language?
jodygrenier
01:20
Learn the Basics of JavaScript at Treehouse
TEAM TREE HOUSE
11:44
html5 canvas animation basics tutorial for beginners javascript programming lesson
Top Football goals
09:39
Reduce basics - Part 3 of Functional Programming in JavaScript
ahmed lembarki
46:20
Day - 37 | 💻 JavaScript Introduction in Hindi | History, Features & Basics Explained
skillwaala