Posts

Showing posts from February, 2021

JavaScript - closure Tutorial Points (4)

Image
Create a separate function using JavaScript closure which accepts the tax percentage and returns a function that accepts the amount and returns the amount after adding tax percentage. Try adding tax percentage to ‘this’ object and check if it works. <! DOCTYPE   html >   < html   lang = "en" >      < head >          < meta   charset = "UTF-8" >          < meta   http-equiv = "XX-UA-Compatible"   content = "IE=edge" >          < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >          < title > AF LAB 01 - Ex 04 </ title >      </ head > < body >   < script >     /*Create a separate function using JavaScript closure which accepts the tax percentage and returns a function that accepts the amount and returns the amount after adding tax percentage. Try adding tax percentage to ‘this’ object and check if it works */   let   taxPercentag

JavaScript - JSON Tutorial Points (3)

Image
Use curly brackets to create JSON like JavaScript object and add properties and functions to the object. JSON is a type of  data-saving format. it saves data using key and value pairs. <! DOCTYPE   html >   < html   lang = "en" >      < head >          < meta   charset = "UTF-8" >          < meta   http-equiv = "XX-UA-Compatible"   content = "IE=edge" >          < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >          < title > AF LAB 01 - Ex 02 </ title >          <!-- JSON is a type of data saving format.it saves data using key and value pairs -->      </ head > < body >   < script >       /*Use curly brackets to create JSON like JavaScript object and add properties and functions to the object */ let   student  = {      first :   "Kamal" ,      second :   "Perera" ,      age :   44 ,      welcome :   f

JavaScript - Data Types and this key word (Part 2)

Image
JavaScript Data types JavaScript Data types one of the most fundamental characteristics of a programming language is the set of data types it supports. These are the type of values that can be represented and manipulated in a programming language.    JavaScript allows you to work with three primitive data types:   Numbers, e.g., 123, 120.50 etc.  Strings of text, e.g. "This text string" etc.  Boolean, e.g. true or false.  JavaScript also defines two trivial data types, null and undefined, each of which defines only a single value. In addition to these primitive data types, JavaScript supports a composite data type known as an object. We will cover objects in detail in a separate chapter. Note: Java does not make a distinction between integer values and floating-point values. All numbers in JavaScript are represented as floating-point values. JavaScript represents numbers using the 64-bit floating-point format defined by the IEEE 754 standard.  

JavaScript - this key Word Tutorial Points (2)

Image
  Understand the ‘this’ keyword in JavaScript.  a. Declare a global variable named vehicle name in the window object.  b. Declare a method named printVehicleName to print out the vehicle name.  c. Declare an object named Vehicle(using object literal notation) which have a variable called vehicle name and declare a function named getVehicleName and assign it with the printVehicleName.  d. Execute the printVehicleName function and the getVehicleName functions to see the results.  e. Correct the getVehicleName to print out the global variable vehicle name using the this keyword <! DOCTYPE   html >   < html   lang = "en" >      < head >          < meta   charset = "UTF-8" >          < meta   http-equiv = "XX-UA-Compatible"   content = "IE=edge" >          < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >          < title > AF LAB 01 - Ex 03 </ title >  

JavaScript - this key Word Tutorial Points (1)

Image
Objective: Teach a set of basic concepts in the JavaScript programming language. Create a function as a variable (function expression) that prints ‘Hello World’ to console and another function that accepts a variable. The argument passed to the second the function should be executed as a function inside the body. Call the second function passing the first function as the argument. <! DOCTYPE   html >   < html   lang = "en" >      < head >         < meta   charset = "UTF-8" >       < meta   http-equiv = "XX-UA-Compatible"   content = "IE=edge" >       < meta   name = "viewport"   content = "width=device-width, initial-scale=1.0" >            < title > Tutorial point - Ex 01 </ title >      </ head > < body >   < script >             /*Create a function as a variable (function expression) that            prints ‘Hello World’ to console */            console . log

JavaScript - Introduction (Part 1)

Image
JavaScript - Introduction  JavaScript is a dynamic computer programming language. It is lightweight and most commonly used as a part of web pages, whose implementations allow client-side script to interact with the user and make dynamic pages. It is an interpreted programming language with object-oriented capabilities.  JavaScript was first known as  Live Script,  but  Netscape  changed its name to  JavaScript , possibly because of the excitement being generated by Java. JavaScript made its first appearance in Netscape 2.0 in 1995 with the name Live Script. The general-purpose core of the language has been embedded in Netscape, the Internet Explorer, and other web browsers. JavaScript is a lightweight, interpreted programming language.  Designed for creating network-centric applications. Complementary to and integrated with Java. Complementary to and integrated with HTML. Open and cross-platform.  Modern JavaScript depends on the idea of the modern browser. What is