The colon (:) can be used when you want to define the property to an object while equal (=) can be used when you want to assign a value to a variable.ExampleFollowing is the code −var studentDetails = { "studentId": 101, "studentName": "John", "studentSubjectName": "Javascript", "studentCountryName": "US" } console.log(studentDetails); var firstName = "David"; console.log(firstName);To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo325.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo325.js { studentId: 101, studentName: 'John', studentSubjectName: 'Javascript', studentCountryName: 'US' } David
To remove child elements, set the innerHTML to ‘’.ExampleFollowing is the code − Document Javascript MySQL Remove the items remove.onclick = () => { const element = document.getElementById("removeAllChildElements"); element.innerHTML = ''; } To run the above program, save the file name anyName.html(index.html). Right click on the file and select the option “Open with live server” in VS Code editor.OutputThis will produce the following output −Now you can click the button “Remove the items”. It will remove all the elements inside the box.OutputThis will produce the following output −
Use the map() function correctly to save elements.ExampleFollowing is the code −const addIndexValueToArrayElement = function (arrObject) { const updatedArrayValue = []; arrObject.forEach(function (ob) { const mapValue = ob.map(function (value) { return value + arrObject.indexOf(ob) }) updatedArrayValue.push(mapValue) }) return updatedArrayValue; }; const output = addIndexValueToArrayElement([ [4, 5], [7, 56], [34, 78], ]); console.log(output);To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo323.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo323.js [ [ 4, 5 ], [ 8, 57 ], [ 36, 80 ] ]
To repeat string, you can use Array() along with join().ExampleFollowing is the code − Document String.prototype.counter = function (value) { return new Array(value + 1).join(this); } console.log("The repeat string".counter(5)); To run the above program, save the file name anyName.html(index.html). Right click on the file and select the option “Open with live server” in VS Code editor.OutputThis will produce the following output: on console −
If you will use equal operator(=) in if condition the if block will always be executed.You need to use == operator or === .ExampleFollowing is the code −var details = [ { id: 10001, name: "John" }, { id: 10002, name: "Bob" }, { id: 10003, name: "Carol" }, { id: 10004, name: "David" } ] var searchId = 10003; for (var index = 0; index < details.length; index++) { if (details[index].id === searchId) { console.log(details[index].id + " found"); break; } }To run the above program, you need to use the below command −node fileName.js.Here, my file name is demo322.js.OutputThis will produce the following output −PS C:\Users\Amit\javascript-code> node demo322.js 10003 found
Getting through all the tedious interview rounds of big tech giants for internships and jobs is in itself a big task. But once you clear the interview rounds and secure a job or an internship, the journey does not end there. In fact, this will be the time you need to upskill yourself in order to keep up with the pace of shift in technological stacks that the tech industry goes throughIn this article, we will be discussing top skills that would be very handy if you would learn it before taking up the job or internship position. We will ... Read More
When you run an application inside a Docker Container, by default it has access to all the root privileges. You might have noticed that when you open an Ubuntu Docker Container Bash, you are logged in as the root user by default. This can prove to be a major concern in terms of security of the application. Any outsider can misuse this and hack the entire Container along with all the other files and applications running inside the Docker Container. Hence, it becomes very important to perform most of the trivial operations as a non root user wherever possible.In this ... Read More
One of the most important features of Docker Containerization is that it creates a bounded environment for running the Application with all the necessary dependencies and packages installed. Most applications require a backend database to store data points. Oracle provides Docker Images for running MySQL inside Containers and thus it becomes an excellent choice for testing your database applications. It provides lightweight MySQL Image instances with cleanup features once your testing is completed.Docker allows you to download the Image containing the MySQL binaries and dependencies and creates a virtual filesystem. Note that if you start a Docker Container with the ... Read More
In this article, we are going to discuss why you should use a user-defined bridge network over default bridge networks. We will also demonstrate the same using practical examples.If you use a user−defined bridge for Container networking, all the Containers in that network automatically exposes all the required ports to each other but not to the external world. This increases interoperability among the containers and provides better isolation.When you create Docker Containers using the default bridge network, accessing each other can only be done using IP addresses. But in case of user-defined bridge networks, you can access them using names ... Read More
There are two types of single−host networks available for Docker Networking - “host” and “bridge” networks. Single−host networks mean that their effect is local to each individual host.In case of a host network, a particular Docker Container can directly use the Networking of the host for sending and receiving the packets. In the case of a bridge network, it requires port mapping to communicate.To understand them better, let’s create a nginx container with the help of host networking. Before creating a nginx container, let’s list all the available networks.sudo docker network lsYou will find a network with the name host ... Read More
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP