Today's Question:  What does your personal desk look like?        GIVE A SHOUT

SEARCH KEYWORD -- javascript



  + operation on JavaScript objects

In JavaScript, there are two types of values: primitive and object. Primitives consist undefined, null, boolean, number and string. Other values such as array and function are objects. When applying + operation on different type of values, there would be three kinds of type conversion. Primitive conversion Number conversion String conversion There three type conversions have corresponding abstract operations in JavaScript: ToPrimitive(), ToNumber(), ToString(). For number additi...

   JAVASCRIPT,PROGRAMMING     2018-10-12 22:19:12

  JavaScript showModalDialog method

In JavaScript, showModalDialog()  method creates a simple modal dialog box which is a simple html page but when a modal dialog opens, user can't switch to another page until it closes the modal dialog box. Syntax:  window.showModalDialog( url, arguments, feature options); Where url is the URL of page which is to be opened in modal window and arguments are those arguments which we are passing to the modal window and feature options are the attributes set for the modal windo...

   JavaScript,JS,showModalDialog,Example     2011-07-27 10:51:47

  7 Resources Every JavaScript Developer Should Know

A web developer today is expected to be an expert in every aspect of their craft and JavaScript is no exception.  Years ago JavaScript seemed to be more of an annoyance, producing those trailers at the bottom of the browser.  This has changed and JavaScript is a first-class citizen as a functional programming language and what seems like an unlimited number of resources covering the language. I have been doing more and more JavaScript lately, both on the front-end and some node.js...

   JavaScript,Resource,Study,Website     2012-03-15 12:54:40

  JavaScript's New Features: Exploring the Latest Additions to the Language

As the web continues to evolve, so too does the JavaScript ecosystem. With the release of ECMAScript 2023 (ES2023), JavaScript developers can now leverage a range of new features that promise to improve code quality, readability, and maintainability. In this blog post, we'll dive into some of ES2023's most exciting additions and provide practical examples of how they can be used in your projects. 1. Private Fields and Methods in Classes One of the most anticipated features in ES2023 is the intro...

   JAVASCRIPT,ES2023     2023-04-16 01:41:58

  Solution to IE setAttribute style problem

In IE7, the JavaScript setAttribute("style","attributes") doesn't work, but it works in IE 8 and other web  browsers. To solve the STYLE problem in IE 7 we can use a workaround method.we can use element.style.cssText = 'color:#FF0000;';in IE 7 instead ofelement.setAttribute('style','color:#FF0000;'); ...

   JavaScript,Style,setAttribute, IE,Not work,Solution     2011-11-21 12:00:27

  JavaScript tips both novice and veteran developers can benefit from

In this post, we will share some less known but powerful JavaScript tips which can benefit both novice and veteran JavaScript developers. 1. Truncate array with array length We all know that object are passed by reference in JavaScript, but we may be bitten by this rule. Please check below example: var arr1 = arr2 = [1, 2, 3]; //Change arr1 arr1 = []; // arr2 will still be [1,2,3] arr1 and arr2 point to the same array [1,2,3] initially, later when arr1 repoints to [], the reference to arr2 is n...

   JavaScript,Array,push     2013-08-21 04:09:10

  Get hostname from a URL using JavaScript

Sometimes we may have strings which contain some UR;s and we may want to retrieve the hostname from the URLs for some statistic use. For example, we may have a URL : http://www.example.com/aboutus.html. We may want to retrieve the www.example.com from the URL. How? Use regular expression. Here I give an example using JavaScript. If you want to check whether a string is a URL or not. Refer to Detect URLs in a Block of Text. In JavaScript, we can have a regular expression like var pattern=/(.+:\/\...

   JavaScript,URL,regular expression, Hostname     2012-06-15 09:16:45

  Why you should be careful about optimizations

In one of my current javascript projects, I have to deal with 3D voxel coordinates. And, sometimes, I have floating points coordinates which must be converted to integers in order to convert them into proper array index. Javascript is a wonderful language, really. However, implementations are sometimes weird, and the way to do something can sometimes have very huge impacts on the performances. Worse, sometimes the classical way is more expensive than the tricky one. So, some peo...

   JavaScript,Bitwise,Floor,Trick,Optimization     2012-05-02 11:29:20

  Going Simple with JavaScript

I was making a change to a page that needed to pull from a remote API and make changes to various parts of the page. Sounds like the time to pull out jQuery and Ajax, doesn't it? Instead, I just used old fashioned JavaScript. Actually, I used new fashioned JavaScript. Browsers haven't stood still in the advent of libraries and frameworks. As a result, we can take advantage of those features when we need to bake in a little extra. Some JSONP The first step was to get the JSONP call execu...

   JavaScript,new version,new addition,JSONP,querySelectorAll     2012-03-06 05:22:59

  Some frequently used ES6 code snippets

Below are a list of ES6 code snippets which are used frequently. Hope that it will be helpful. 1. Shuffle array elements let arr = [67, true, false, '55'] arr = arr.sort(() => 0.5 - Math.random()) console.log(arr) // [ '55', 67, false, true ] 2. Remove characters which are not numbers const str = 'xieyezi 23213 is 95994 so hansome 223333' const numbers = str.replace(/\D/g, '') console.log(numbers) // 2321395994223333 3. Reverse sequence or words const sentence = 'xieyezi js so handsome, lol.'...

   JAVASCRIPT,ES6,CODE SNIPPET,TIPS     2022-04-10 07:56:07