- 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 6685 Articles for Javascript
![Ali](https://www.tutorialspoint.com/assets/profiles/14292/profile/60_101553-1513052445.jpg)
203 Views
To print a message to the error console, use the console object. Here’s an example −The following will show a red error message −console.error(message);The following gives you the default message −console.log(message);The following gives you the warning message −console.warn(message);The following gives an information message −console.info(message);Add CSS to the log message −console.log('%c Add message!, "background: green; color: white;");Use the following to print error. Consider “num” as the variable name −console.error('num=%d', num);For complete API reference, refer Console API Reference.
![Saurabh Jaiswal](https://www.tutorialspoint.com/assets/profiles/500262/profile/60_1406912-1660202490.jpg)
7K+ Views
With JavaScript, you can easily access/ read cookies with the “document.cookie” property. Reading a cookie is just as simple as writing one because of the value of the document.cookie object is the cookie. The document.cookie string will keep a list of name=value pairs separated by semicolons, where the name is the name of a cookie and value is its string value. In this article, we will learn how to access cookies using document object in JavaScript. Syntax document.cookie Return value − All the cookies are saved in the browser in a single string. The document.cookie string will keep ... Read More
![Ali](https://www.tutorialspoint.com/assets/profiles/14292/profile/60_101553-1513052445.jpg)
222 Views
To print debug messages in the Google Chrome JavaScript Console, write a script, which is not creating console functions if they do not exist −if (!window.console) console = {}; console.log = console.log || function(){}; console.warn = console.warn || function(){}; console.error = console.error || function(){};Above you can see the following functions are used to log items based on a log, warn or info. It won’t cause errors when the console isn’t available. The following functions work in Google Chrome console −console.log( ); console.warn(); console.error();The Console object is used to access the browser's debugging console. As an example, consider the Web Console ... Read More
![Prabhas](https://www.tutorialspoint.com/assets/profiles/13554/profile/60_90506-1512543588.jpg)
6K+ Views
You can extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set cookies to expire in 30 minutesLive Demo Enter name:
![Johar Ali](https://www.tutorialspoint.com/assets/profiles/14293/profile/60_101691-1513053093.jpg)
198 Views
To print content of JavaScript object, you can try to run the following code. Here, the object is created using the new keyword −ExampleLive Demo var dept = new Object(); dept.employee = "Amit"; dept.department = "Technical"; dept.technology ="C++"; document.getElementById("test").innerHTML = dept.employee + " is working on " + dept.technology + " technology.";
![seetha](https://www.tutorialspoint.com/assets/profiles/13549/profile/60_42938-1512640859.jpg)
8K+ Views
You can extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set cookies to expire in 1 hour − Enter name:
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
18K+ Views
In this tutorial, we will learn to clear all cookies using JavaScript. The cookies are the text or data stored in the format of text files in the browser or user's computer, and it is one kind of cache memory. The developer can store the username, authentication tokens, etc., in the browser's cookies. When a user visits the webpage for the first time, it retrieves the user information from the server and stores it in the cookie format in the browser. After that, when a user visits the webpage again, it retrieves the required data from cookies instead of the ... Read More
![radhakrishna](https://www.tutorialspoint.com/assets/profiles/13544/profile/60_40618-1512640354.jpg)
5K+ Views
Extend the life of a cookie beyond the current browser session by setting an expiration date and saving the expiry date within the cookie. This can be done by setting the ‘expires’ attribute to a date and time.ExampleYou can try to run the following example to set the expiry date of a cookie by 1 Month − Enter name:
![Rishi Rathor](https://www.tutorialspoint.com/assets/profiles/13563/profile/60_89283-1512714754.jpg)
654 Views
Using cookies is the most efficient method of remembering and tracking preferences, purchases, commissions, and other information required for better visitor experience or site statistics.The simplest way to create a cookie is to assign a string value to the document.cookie object, which looks like this.document.cookie = "key1=value1;key2=value2;expires=date";Here the expires attribute is optional. If you provide this attribute with a valid date or time, then the cookie will expire on a given date or time and thereafter, the cookies' value will not be accessible.Note − Cookie values may not include semicolons, commas, or whitespace. For this reason, you may want to ... Read More
![Shubham Vora](https://www.tutorialspoint.com/assets/profiles/485898/profile/60_1456867-1657516792.jpeg)
251 Views
In this example, we will learn how the prototype works in JavaScript. It is rare if a JavaScript developer doesn’t use the objects while developing the functions, and the objects can make a lot of work easy for developers.The prototype is also the advanced concept associated with the objects in JavaScript. Many of you have heard about the prototypes for the first time but don’t worry. We will cover all things about the prototypes in this tutorial.What does the prototype do?The prototype is the object created for every function class when the program starts execution. However, it depends on the ... Read More