- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9297 Articles for Object Oriented Programming
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
1K+ Views
Following is the code to convert 24 hours format to 12 hours in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 18px; font-weight: 500; color: rebeccapurple; } Convert 24 hours format to 12 hours Hours Minutes CLICK HERE Click on the above button to convert the above 24 hour format to 12 hour format let resEle = document.querySelector(".result"); let BtnEle = ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
560 Views
JavaScript treats functions as objects and allow us to pass functions as parameter to another function and even return functions from other functions. In JavaScript the functions are first class functions meaning we can store them in variable, objects and array. The higher order functions can take function, return them or do both.Following is the code to implement first class functions in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 18px; font-weight: ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
391 Views
JavaScript has the following values evaluate to false when evaluated as Boolean type − false0empty string: "" , '' , or ``nullundefinedNaN — not a number valueFollowing is the code for identifying falsy values in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result{ font-size: 20px; font-weight: 500; color: blueviolet; } Identifying Falsy values in JavaScript. CLICK HERE Click on the above button to identify some of the ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
319 Views
Following is the code for implementing linear search in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result,.sample { font-size: 20px; font-weight: 500; color: blueviolet; } .sample{ color:red; } Implementing linear search [1,19,5,11,22,55] CLICK HERE Click on the above button to search for 22 in the above array let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); let arr = [1,19,5,11,22,55]; BtnEle.addEventListener("click", () => { for(let i=0;i
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
128 Views
In ES6, if the object key name and variables passed as properties value have same name then we can simply omit the value name and only specify the key name.Following is the code for property shorthands in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; color: blueviolet; } ES6 Property Shorthands in JavaScript CLICK HERE Click on the above ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
97 Views
Note − You will need a localhost server to run this example −Following is the code for dynamic imports in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 18px; font-weight: 500; color: rebeccapurple; } Awaiting on dynamic imports in JavaScript CLICK HERE Click on the above button to dynamically import modules document.querySelector(".Btn").addEventListener("click", loadModule); let resEle = document.querySelector(".result"); async function loadModule() { ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
425 Views
Following is the code for nesting template strings in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result { font-size: 20px; font-weight: 500; color: blueviolet; } Nesting template strings in JavaScript CLICK HERE Click on the above button to display the fullName using nested template string let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); function fullName(fName, lName) { return fName + " " + lName; } let firstName = "Rohan"; let lastName = "Sharma"; BtnEle.addEventListener("click", () => { resEle.innerHTML = `FirstName = ${firstName} and lastname = ${lastName} and fullname = ${fullName( `${firstName}`, `${lastName}` )}`; }); OutputOn clicking the ‘CLICK HERE’ button −
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
288 Views
The call(), apply() and bind() are used to borrow methods in JavaScript.Following is the code for borrowing methods in JavaScript −Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result, .sample { font-size: 18px; font-weight: 500; color: rebeccapurple; } .result { color: red; } Borrowing a method in JavaScript CLICK HERE Click on the above button to borrow the welcome method of object obj ... Read More
![AmitDiwan](https://www.tutorialspoint.com/assets/profiles/123055/profile/60_187394-1565938756.jpg)
75 Views
Following is the code to transform JavaScript arrays using maps.Example Live Demo Document body { font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif; } .result,.sample { font-size: 18px; font-weight: 500; color: rebeccapurple; } .result { color: red; } Transform JavaScript arrays using maps [22,33,44,55] CLICK HERE Click on the above button to square each element of the above array let resEle = document.querySelector(".result"); let BtnEle = document.querySelector(".Btn"); let arr = [22, 33, 44, 55]; BtnEle.addEventListener("click", () => { resEle.innerHTML = arr.map((a) => a * a); }); OutputThe above code will produce the following output −On clicking the ‘CLICK HERE’ button −
![Vasireddy Bindu Hasitha](https://www.tutorialspoint.com/assets/profiles/1086615/profile/60_1039022-1713852043.jpeg)
288 Views
What is a Higher Order Function in JavaScript? JavaScript being a multi paradigm language, it supports procedural programming, functional programming and object oriented programming. Since it is also a functional programming language javascript handles functions as a first class entities, where functions can be assigned to a variable, set it as an object's property, and can pass them as an argument to another function. This characteristic in javascript helps in implementing Higher Order Functions, which can operate on other functions either by taking them as an argument or by returning them. Let us take an example and implement it ... Read More