What is JavaScript ? Introduction of JavaScript

What is JavaScript ? Introduction of JavaScript

JS

JavaScript

{tocify} $title={Table of Contents}

What is JavaScript?

JavaScript is a programing or a scripting language that allow the implementation of features on web pages.

To better understand JavaScript, we are able to examine what we already know.

we all know that Hypertext nomenclature (HTML) elements are the building blocks of sites.

Ans, Cascading Style Sheet(CSS) is employed for designing HTML elements.

JavaScript on the other hand, is what implements the features of web pages.

What do you learn before learning JavaScript? 
In order to learn JavaScript, you need to have:

  • PC education.
  • Basic understanding of HTML.
  • Basic understanding of CSS.

What can JavaScript do?

  1. JavaScript can change the content of HTML elements.
  2. JavaScript can change the styling of HTML element.
  3. JavaScript can change the value of the attributes.

JavaScript Cheat Sheet

JavaScript Basics

1.Including JavaScript in an HTML page:

<script>
// JavaScript code
</script>

2.Call an External JavaScript File:

<script src="main.js"></script>

3.Including Comments:

<script src="main.js">
//Single line comments
/* multi-line comments
multi-line comments
multi-line comments */
</script>

Variables

1.var, count, let

var: The most widely recognized variable. Can be assigned yet just got to inside a capacity. Factors characterized with var move to the top when code is executed.

const: Can not be reassigned and not accessible before they appear within the code

let: Similar to const, however, let variable can be reassigned but not re-declared.

 2.Data Types:

var age=23 Numbers.
var x Variables.
var a=”Poorwebdev” text(string).
var b = 1+2+3 Operators.
var c = true True or False statement.
const PI =3.14 Constant numbers.
var name ={FirstNmae:”John”,LastName:”Doe”} Object.

3.Objects:


var person={
firstName:"jone",
lastName:"Doe",
age:"20",
nationality:"india"
};

Operators

1.Basic Operators:

+ Addition.
Subtraction.
* Multiplication.
/ Division.
(..) Grouping operator.
% Modulus.
++ Increment numbers.
Decrement numbers.

2.Comparison Operators:

== Equal to.
=== Equal value and Equal type.
!= Not Equal.
!== Not Equal value and not Equal type.
> Greater than.
< Less than.
>= Greater than equal to.
<= Less than equal to.
? Ternary operator.

3.Logical Operators:

&& Logical and.
|| Logical or.
! Logical not.

4.Bitwise Operators:

& AND statement.
| OR statement.
~ NOT.
^ XOR.
<< Left shift.
>> Right shift.
>>> Zero fill right shift.

Arrays


var fruit = ["Banana", "Apple", "pear"];

Array Methods:

concat() Join several arrays into once.
indexOf() Returns the first position at which a given element appears in an array.
join() Combine element of an array into a single string and return the string.
lastIndexOf() Given the last position at which a given element appears in an array.
pop() Removes the last element from an array.
push() Add a new element at the end of the array.
reverse() Reverse the first order of the element in an array.
shift() Remove the first element in an array.
slice() pulls a copy of a portion of an array into a new array.
sort() Sort elements alphabetically.
splice() Add elements in a specified way and portion.
toString() Converts elements to a string.
unsift() Add a new element to the beginning.
valueOf() Returns the primitive value of the specified object.

Function


function name(parameter1, parameter2, peramoter3) {
//what the function does
}

1.Outputting Data:

alert() Output data in an alert box in the browser window.
confirm() Opens up a yes/no dialog in the browser window.
console.log() Write information to the browser console, good for debugging purposes.
document.write() write directly to the HTML document.
prompt() Creates a dialogue for user input.

2.Global Function

decodeURI() Decode a Uniform Resource Identifier (URI) created by encode URI or similar.
decodeURIComponent() Decode a URI component.
encodeURIComponent() Same but for URI component.
eval() Evaluates JavaScript code represented as a string.
isfinite() Detects whether a value is non or not.
Number() Return a number converted from its argument.
parseFloat() Parses an argument and returns a floating point number.
parseInt() Parses its argument and returns an integer.

Tags: No tags

One Response

Add a Comment

Your email address will not be published. Required fields are marked *