Jump to content

Search the Community

Showing results for tags 'javascript'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • General
    • General Discussion
    • Artificial Intelligence
    • DevOps Forum News
  • DevOps & SRE
    • DevOps & SRE General Discussion
    • Databases, Data Engineering & Data Science
    • Development & Programming
    • CI/CD, GitOps, Orchestration & Scheduling
    • Docker, Containers, Microservices, Serverless & Virtualization
    • Infrastructure-as-Code
    • Kubernetes
    • Linux
    • Logging, Monitoring & Observability
    • Security
  • Cloud Providers
    • Amazon Web Services
    • Google Cloud Platform
    • Microsoft Azure
    • Red Hat OpenShift

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


LinkedIn Profile URL


About Me


Cloud Platforms


Cloud Experience


Development Experience


Current Role


Skills


Certifications


Favourite Tools


Interests

Found 9 results

  1. We're thrilled to introduce our new, high-performance JavaScript SDK. We reduced the package size by 70% and the load time by 60%. Read our blog to learn more.View the full article
  2. In JavaScript, the console object gives access to the browser to allow for debugging. It is used for different objectives, including displaying messages, alerts, and errors on the browser console. Therefore, it is very useful for debugging purposes. Most popular web browsers, including Firefox, Google Chrome, Safari, etc., provide a set of developer tools that consists of a debugger, console, inspect element, and network activity analyzer. Through these tools, it has become easier to perform any tasks according to the requirements. In this post, the console in JavaScript is briefly explained with the following learning outcomes: How to use the console object in JavaScript How various console methods work in JavaScript How to use the console object in JavaScript? In JavaScript, a console is an object combined with different methods to perform various functions and get the output on the browser. Some of the console methods in JavaScript are as follows: console.log() method: Output the message to the web console. console.Info(): output an informational message to the web console console.error(): Displays an error message on the console. console.Clear(): Removes everything from the console. console.warn(): Displays a warning message. console.assert(): Return an error message if the assertion fails. console.count(): Return the number of counts called. console.table(): Returns data in a tabular format. console.Group(): Creates a group inline in the console. console.GroupEnd(): End the current group in the console. console.Time(): Starts a timer for the console view. console.timeEnd(): End the timer and return the result to the console. In order to provide a better understanding, a few examples are provided. How does the console.log() method work in JavaScript? The console.log() method displays the output to the console. Users can input any type inside the log(), such as strings, booleans, arrays, objects, etc. The example code of the console.log() method is given below. Code: // console.log() method console.log("welcome to JavaScript") // string console.log(1); // boolean console.log([1, 2, 3]); // array inside log console.log(true); // boolean console.log(null); In the above code, the console.log() method is used to print the string, a boolean and an array on the console. Output: It is observed that the string, boolean, and array values are printed on the console. How does the console.info() work in JavaScript? The console.info() method displays the key information regarding the user in accordance with the needs. Most of the developers used this method for displaying permanent information. Code: // console.info() method console.info("This is an information message"); In the above code, a string is passed using the console.info() method. Output: In the console window, string output is displayed by using console.info() method. How does the console.error() method work in JavaScript? To display the error message, the console.error() method is used. Most of the developers used it for troubleshooting purposes. The example code of the console.error() method is given as follows. Code: // console.error() method console.error('This is a simple error'); The console.error() method executed in the console browser is marked as a string input in the below figure. Output: By passing a single argument of string type, the error message is displayed on the console. How does the console.clear() method work in JavaScript? The console.clear() method is used for removing all the information from the console browser. Most of the time, it is used at the start of the code to remove all previous information or to display a clean output. Code: // console.clear() method console.clear(); The console.clear() method is used as input in the console browser. Output: Let’s look at the state of the console before applying the console.clear() method. Now, observe the console after applying the clear() method. The output figure shows a clear display in the console window using the console.clear() method. How does the console.warn() method work in JavaScript? The console.warn() method is used to show the warning message to the console browser. It requires only one argument to display the message. The JavaScript code is as below: Code: // console.warn() method console.warn('This is a warning.'); A simple warning message is being printed using the warn() method. Output: The output shows a warning symbol and the message you entered in the console.warn() method. How does the console.count() method work in JavaScript? The console.count() method shows how many times a method has been called. Below is the code for the console.count() method. Code: // console.count() method for(let i=1;i<6;i++){ console.count(i); } In the above code, the console.count() method is used to count the methods within a loop. Output: The figure shows that five counts are called in a for loop using the console.count() method. How does the console.table() method work in JavaScript? The console.table() method is used to display objects in the form of a table on the browser console. We made use of the following code to show the usage of the console.table() method. Code: console.table({'a':1, 'b':2,'c':3,'d':4}); The console.table() method is used to represent the data in a tabular form. Output: The below figure shows a table in which values are stored by assigning indexes. How does the console.time() and console.timeEnd() methods work in JavaScript? The console.time() method is used to start calculating the execution time of a specific portion of code. Moreover, at the end of the code, you can use console.timeend() to get the execution time. The following example code implements the console.time() and console.timeend() methods. Code: // console.time() and console.timeEnd() method console.time('Welcome to JavaScript'); let fun_sit = function(){ console.log('fun_sit is running'); } let fun_stand = function(){ console.log('fun_stand is running..'); } fun_sit(); // calling fun_sit(); fun_stand(); // calling fun_stand(); console.timeEnd('Welcome to JavaScript'); In the above code, The console.time() method is used at the After that, two functions are created. Later, these functions are Lastly, we used the console.timeend() method to return the total execution time of the code (that is placed in between the console.time() and console.timeEnd() methods). Output: It is observed from the output that the code written between the console.time() and console.timeEnd() methods took 8.96 ms to execute. How does the console.group() method work in JavaScript? The console.group() method is used to make a group of messages on the console. Additionally, the console.groupEnd() method is used to terminate that group. The example code that exercises console.group() and console.groupEnd() methods is written below. Code: // console.group() and console.groupEnd() method console.group('simple'); console.warn('alert!'); console.error('error notification'); console.log('Welcome to JavaScript'); console.groupEnd('simple'); console.log('new section'); In above code, console.group() method is used. After that, the warn(), error(), and log() methods are used for displaying messages in the group. At the end, console.groupEnd() is used to end the messages of the group. Output: The output illustrates the group of messages in which errors and warning notifications are displayed. whereas the statement ‘new section’ is displayed outside of the group. Here it is! You have learned to understand and apply console objects and their methods in JavaScript. Conclusion In JavaScript, the console object comprises various methods that can be used to get the output on the browser’s console. This post demonstrates the functionality of the console in JavaScript. You have learned to access the console of various browsers. Additionally, we have provided an overview of all the methods supported by the console object in JavaScript. View the full article
  3. Today we are announcing the general availability of Geofences for Amplify Geo. Amplify Geo enables frontend developers to add location-aware features to their web applications. Developers looking to display geometric boundaries or Geofences on a map, can now implement a complete Geofence management solution in minutes using the cloud-connected UI widget and APIs from Amplify Geo, powered by Amazon Location Service. Geofences are geometric boundaries that can be drawn around places of interest or areas on a map. View the full article
  4. JavaScript is a high-level scripting language used by programmers worldwide to perform dynamic and interactive operations on websites. So, every high-level language needs to be converted into a computer understandable language before execution and for that purpose, compilers and interpreters are used. In this article, we are excited to tell you about our list of best 5 JavaScript IDEs ... View the full article
  5. Array reversing is a very well-known programming challenge that a developer can encounter at any time. Therefore JavaScript provides multiple ways to deal with it such as using for-loop, reverse(), unshift() method, swapping technique etc. Some of them modify the original array while some approaches don’t affect the original array. This post will explain the below-mentioned approaches to reverse an array in JavaScript: How to use Array.reverse() Method in JavaScript How to use Traditional for-loop in JavaScript How to use Array.unshift() method in JavaScript So, let’s begin! … View the full article
  6. Application developers building real-time audio, video, and screen sharing applications can now collect client metrics from meetings events available from the Amazon Chime SDK for JavaScript. Developers can help end users troubleshoot their application without requiring them to send in client logs. And by streaming metrics to Amazon CloudWatch, developers can analyze meeting health trends or deep dive on problematic meetings or devices. View the full article
  7. Javascript is the language of freedom yet is a function-oriented language at the same time. Unlike other languages, javascript does not provide a built-in sleep() function. You can either build a custom sleep() function using the built-in setTimeout() function, or the latest ECMAScript promises an async-await function. This article shows you how to stop or pause the execution of the sleep function for a desired amount of time using promises or async-await functions... View the full article
  8. Do you love JavaScript? Did you write a new framework or library? Do you want to showcase your emulator able to run Windows 98 in Chrome? Or finally got that retro game to run in the browser? THIS IS THE CONFERENCE FOR YOU! Join us for the online conference Conf42.com: JavaScript, that’s all about JavaScript and the crazy things you can do with it! We’re looking for presenters on topics such as: new frameworks and libraries for JavaScript languages that compile into JavaScript Node.js new, innovative uses of JS anything that makes it easier to build frontends JavaScript games https://www.papercall.io/conf42-javascript-2021
  9. Javascript is a web-oriented programming language. When using the web, you will often need to navigate through pages. When you click on any button, submit a form, or log in to any website, you get redirected to a different new page. Page redirection is an essential part of any website, but it is not only restricted to page navigation on a website. There can be multiple reasons to redirect the page, for example: The old domain name is changed to a new domain Submission and Authorization of a form On the base of the browser or language of the user Redirect from HTTP to HTTPS This article explains a few different ways to redirect a page. Syntax The syntax for navigating to a page using javascript is as follows: window.location.href = "url" In this method, you simply provide the URL to which you want to redirect the user. The syntax for another method of redirecting a user to a new URL is as follows: window.location.replace("url") // or window.location.assign("url") In this functional syntax, you provide the URL to which you want to redirect, and whenever this function is called, you will be redirected to that specific URL. Here, “replace” and “assign” do the same task but with a subtle difference. They both redirect to a new URL, but “replace” does not take the record of history and the user cannot go back to the old URL or previous page. Meanwhile, “assign” keeps the history record and allows the user to go back to the previous page. We will now look at some examples of both syntaxes. Examples First, we will create an on-click function on a button. <button onclick="redirectFunction()">Linuxhint</button> This function will redirect the user to the website “https://www.linuxhint.com.” function redirectFunction() { window.location.href = "https://www.linuxhint.com" } Now, if the user clicks on the button, they will be redirected to linuxhint.com In this next example, say, you want to redirect the user from an old domain to the new domain. For testing purposes, suppose the current address is the localhost, but whenever the user enters the URL of the localhost, the user gets redirected from the localhost to the new URL, which is linuxhint.com in this example. This is easier to do than you may think. To do this, simply use the syntax of the second redirect method: window.location.replace("https://www.linuxhint.com") Now, if the user enters the localhost URL, they will be redirected to linuxhint.com. But, if you look at the top-left button of the browser for going back to the previous page: the button is dulled and the browser is not allowing us to go back to the previous page. However, if you want to keep this option for the user, you can use “assign” instead of “replace.” window.location.assign("https://www.linuxhint.com") And now, if you look at the top-left button of the browser for going back to the previous page: The button is not dulled. You can go back to the previous page. It is recommended to use “replace” instead of “assign,” here, because the purpose of redirecting to a new URL is that the old URL is not working or not available anymore. Conclusion This article explained a few different methods of redirection in javascript, along with real-life examples using these methods. In this article, you have learned how to navigate to a new page and how to redirect from the old URL to a new URL. You can learn more about javascript at linuxhint.com. View the full article
  • Forum Statistics

    42k
    Total Topics
    41.9k
    Total Posts
×
×
  • Create New...