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

SEARCH KEYWORD -- console



  A small trick on using console.log to print data in JavaScript

When debugging JavaScript application, one may frequently use console.log to print data so that it is easy to debug when issue occurs and also helps on understand the data flow. The common way of printing a variable would be something like.  let user = { name: "test" }; console.log(user); In this case it will print: { name: 'test' } This is OK when there is no much logging or the program is not complicated. But it becomes difficult to debug if there are lots of variables to be printed ...

   JAVASCRIPT,CONSOLE.LOG,DEBUGGING     2019-09-03 10:24:24

  Run MySQL on Command Line in Windows

Sometimes if we want to run MySQL but we don't have phpMyAdmin installed. What should we do?On Windows we can run MySQL in following steps:Open Console Window->Type "mysqld -u root". This means we start the mysql server with username root. This program will handle all the communications between our console window and the actual data;After starting the server, we need to use a client to connect to the server and communicate with it. the mysql program is right for this. Next in the command cons...

   mysql,console,command line,windows,defau     2011-08-21 04:14:58

  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

  Sony is to release PlayStation4 in 2015

According to Japanese media, Sony may release its flagship game console PlayStation 4 in the Christmas 2013, codenamed Orbis, As the source of the message is very reliable, so the possibility of a new generation of Sony PlayStation 4 game console to the market next year is still quite large. Sony has registered the Orbis domain name, but people are still unable to obtain relevant news on the Orbis website. The release plan on the Sony PlayStation4 game console will be officially launched this s...

   Sont,PS4,PlayStation,High resolution     2012-04-04 08:44:13

  Remove duplicated elements in JavaScript array

During interviews, one frequent question asked would be something like how to remove duplicated elements in a JavaScript array and how many different ways you can think of. The interviewee would also be asked to write the code down. In real applications, normally front end would not need to handle this case since normally it would be done by backend, but still it's necessary for front end developers to know different ways of doing this. This post will share some of the common ways to remove dupl...

   JAVASCRIPT,ARRAY,DUPLICATED ELEMENT     2018-09-21 22:32:10

  Understand JavaScript prototype

For an front end programming language like JavaScript, if we want to understand its OOP feature, we need to understand its objects, prototype chain, execution context, closure and this keyword in deep. If you have a good understanding on these concepts, you should be confident that you can handle this language well. The inheritance in JavaScript is not class inheritance like Java, but it adopts another mechanism-- prototype inheritance. The key to prototype inheritance is the prototype chain mec...

   JavaScript, prototype, __proto__     2013-02-02 02:34:09

  The evolving history of asynchronous operation in JavaScript

JavaScript is single threaded, it means there would be only one task running at any point of time. But this would slow down the overall program execution if there is long running task, hence asynchronous task execution is desired in complex cases. To achieve asynchronous task execution, there are a few options introduced in JavaScript. setTimeout/setInterval Event Promise Async/Await setTimeout/setInterval is one of the first mechanisms introduced in JavaScript to simulate asynchronous operati...

   JAVASCRIPT,ASYNC,PROMISE,AWAIT     2019-11-09 08:21:56

  File upload in PHP

File is a special kind of form data, when being uploaded to the server through HTTP POST request, PHP will create a $_FILES global array, the relevant file information will be stored in this global array. We will illustrate file upload with some code snippets using PHP and look into the internal work mechanism. Lastly will talk about file upload security. File upload In order for users to upload files in client side, we have to provide a form on the user interface. Since the uploaded file is a s...

   File upload,PHP     2012-11-30 22:01:28

  Mastering Async/Await in JavaScript: A Comprehensive Guide with Examples

As a veteran JavaScript developer, I have seen the evolution of JavaScript's asynchronous programming landscape. From callbacks to promises and now async/await, JavaScript has come a long way in making it easier to handle asynchronous operations in a clean and readable manner. In this article, we will delve into the world of async/await and explore why it has become a popular choice for handling asynchronous operations in JavaScript. We will cover the basics of async/await, its syntax, and how i...

   JAVASCRIPT,COMPARISON,PROMISE,ASYNC AWAIT     2023-02-12 07:26:15

  Gracefully exiting from console programs in Ruby

Imagine you write a CLI program or a Rake task which loops through some data performing some work on it. You run it and then you remembered something. You’d love to kill the process with ctrl-c, but that will raise an exception somewhere in the loop. What you want is for the iteration to complete and then you want the program to quit. You could handle the Interrupt exception or add some conditions. But how about a cleaner and reusable way? No problem - you can trap signals, which...

   Ruby,Exit,Command window,Console,Graceful     2012-03-14 13:42:16