Total time: 25 minutes 
Updated: July 22nd, 2020
pi
PRIMARY
215 guides
python
67 guides
apple
51 guides
Calling all writers!

We’re hiring. Write for Howchoo

pi
PRIMARY
215 guides
python
67 guides
apple
51 guides
Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
For Raspberry Pi beginners who still love to follow along in a book.
Michael's profile picture MichaelView
In these interests: booksretropiepi
What’s better than an experiment? An experiment in space!
Michael's profile picture MichaelView
In these interests: kidspinews
In these interests: pi
Kali Linux is a great distribution for Raspberry Pi users who want to get to grips with security testing.
The Raspberry Pi micro-computer grows in power with each new model release, with more resources that make it a more capable, low-cost content server for your media and resources.
Laptops, smartphones, tablets, even lightbulbs—an endless number of devices now have the ability to connect to your local network and the wider internet.
The Raspberry Pi was designed to boot from an SD card, but in some cases, it’s convenient to boot from a USB drive.
Get the new official Raspberry Pi OS on your Pi.
New to the Raspberry Pi? Start here.
Blocking ads just got easier with Pi-hole, a network-wide ad blocker for the Raspberry Pi
Don’t skip out on a proper case for your Pi 4.
The only Raspberry Pi Bluetooth guide you’ll ever need.
Your favorite MS OS on the Pi.
pi
PRIMARY
The Raspberry Pi is a small, inexpensive computer developed by the Raspberry Pi Foundation in the United Kingdom.
Python is howchoo’s favorite programming language. We believe python promotes the most organized and performant codebase possible. We also love Django so, naturally, we love Python.
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

How to Split a String into an Array in JavaScript

Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020

Learn how to split a string into an array.

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides

How to Split a String into an Array in JavaScript

javascriptcode
Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020
Jeremy
1
 

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides
javascript
PRIMARY
27 guides
code
68 guides
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

1
 
In these interests
javascript
PRIMARY
27 guides
code
68 guides
javascript
PRIMARY
27 guides
code
68 guides
PRIMARY

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

The split method splits a string into an array of strings by separating it into substrings. This tool is extremely useful. As an example, we’ll take apart the query string parameters of a URL.

var url = "http://www.example.com/category/page?query=true&query2=false"; // Split off the query string parameters var query = url.split("?")[1]; // "query=true&query2=false" // Now split up the params var params = query.split("&"); // ["query=true", "query2=false"] // Loop through the params and split the key and the value for (var i=0; i < params.length; i++) { console.log(params[i].split("=")[0], params[i].split("=")[1]); } // query true // query2 false

String.split

Calling all writers!

We’re hiring. Write for Howchoo

Jeremy's profile pictureJeremy
Joined in 2015
Programmer, brogrammer, whoagrammer.
Jeremy's profile picture
Share this guide!
RedditEmailText
Related to this guide:
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Zach's profile pictureViewcodejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
People also read:
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
At some point you’ll want to read, set, and remove cookies using JavaScript.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API.
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Learn Multiple Ways to Iterate Over JavaScript Object Properties and Values
The Difference Between “for…in” and “for…of” in JavaScript
JavaScript for loops
How to Turn an Object into Query String Parameters in JavaScript
Unit Testing in JavaScript – Mocha, Chai and Sinon – a Beginner’s Guide
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
At some point you’ll want to read, set, and remove cookies using JavaScript.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API.
How to Copy an Object in JavaScript
How to Manage Cookies in JavaScript
How to Join All Elements of an Array in JavaScript
How to Merge Two Arrays in JavaScript
Determine if a Tab has Focus in JavaScript
Posted in these interests:
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
codecode
Code is poetry — one line at a time.
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
PRIMARY
Explore
codecode
Code is poetry — one line at a time.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate

How to Use Custom Key Mappings in Vim

Total time: 2 minutes 
Updated: July 22nd, 2020

I find Vim to be very useful in my daily development activities. I was delighted to learn that you can have your own key mappings in Vim. It is documented very well in the vim help section. But if you want a quick gist of what is available this post is for you.

Posted in these interests:

vim
PRIMARY
23 guides
code
68 guides

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

How to Use Custom Key Mappings in Vim

Total time: 2 minutes 
Updated: July 22nd, 2020

I find Vim to be very useful in my daily development activities. I was delighted to learn that you can have your own key mappings in Vim. It is documented very well in the vim help section. But if you want a quick gist of what is available this post is for you.

Posted in these interests:

vim
PRIMARY
23 guides
code
68 guides

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

Jump to step

How to Use Custom Key Mappings in Vim

Total time: 2 minutes 
Updated: July 22nd, 2020

I find Vim to be very useful in my daily development activities. I was delighted to learn that you can have your own key mappings in Vim. It is documented very well in the vim help section. But if you want a quick gist of what is available this post is for you.

Posted in these interests:

vim
PRIMARY
23 guides
code
68 guides

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

How to Use Custom Key Mappings in Vim

Total time: 2 minutes 
Updated: July 22nd, 2020

I find Vim to be very useful in my daily development activities. I was delighted to learn that you can have your own key mappings in Vim. It is documented very well in the vim help section. But if you want a quick gist of what is available this post is for you.

Posted in these interests:

vim
PRIMARY
23 guides
code
68 guides

How to Use Custom Key Mappings in Vim

vimcode
Total time: 2 minutes 
Updated: July 22nd, 2020
Ashley
1
 

Posted in these interests:

vim
PRIMARY
23 guides
code
68 guides
vim
PRIMARY
23 guides
code
68 guides
PRIMARY
Jump to step
Calling all writers!

We’re hiring. Write for Howchoo

1
 
In these interests
vim
PRIMARY
23 guides
code
68 guides
vim
PRIMARY
23 guides
code
68 guides
PRIMARY
Jump to step

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

I am picking a simple example from the vim help documentation itself so you can quickly understand what is going on. Suppose you want a quick way of inserting today’s date below your current cursor position. EG:

cursor was here| "Now hitting leader followed by 2 d keys will print the line below
Date: Tue Mar 17 16:11:47 IST 2015

Here is the mapping you can define in your ~/.vimrc

map dd oDate: :read !datekJ

I will try to break down what the above key mapping does does in the steps below. Note Leader is mapped to ** by default. You can optionally change it to any other key. Spacebar** is a good option which can be achieved with the following mapping in my ~/.vimrc file

let mapleader = " "

You can define custom mappings in ~/.vimrc so that they are permanent across your vim sessions. To define mappings for your current session you can type

:map dd oDate: :read !datekJ

which will save your mapping for the current session. If you define new mapping in your ~/.vimrc, you may need to run

source ~/.vimrc

in your current shell for your new mappings to reflect.

Simple Example

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

In the above example we trigger our key mapping by typing dd in normal mode. Key mappings can be defined for different modes as listed below

:map       Normal, Visual and Operator-pending
:vmap      Visual
:nmap      Normal
:omap      Operator-pending (Eg: dw where d is operator character and w is motion character)
:map!      Insert and Command-line
:imap      Insert
:cmap      Command-line

Triggering our custom key mapping

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

Once we trigger our custom key binding we ask it to perform some commands. In this case

oDate: :read !datekJ

The break down

o -> Insert a line below current cursor position and switch to insert mode
Date -> Type the text "Date"
 -> Bring us out of insert mode and into normal mode
: -> This character takes vim to the command line where you can execute commands
read ->  Vim command to Insert output below the cursor(typically from a file) (:help :read)
!date -> ! is a way to execute a shell command in vim. eg: try !ls
 -> This is like hitting enter.  (:help key-notation)

What the above commands does is print the following output below the current cursor position

cursor was here
2 Date:
Tue Mar 17 16:11:47 IST 2015

Now the kJ do the following

k -> Move the cursor up by one line
J -> Join the lines together

Final output:

cursor was here
2 Date: Tue Mar 17 16:11:47 IST 2015

Providing commands

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

You can get a similar shortcut in insert mode with the following mappings.

imap dd Date: :read !datekJA

Slight difference here

Date: -> Since already in insert mode type enter to go to next line and then type Date.
 -> Bring us out of insert mode and read the date as before

To bring us back to insert mode we finish with A in the end. Note Based on feedback, I learnt that mapping in insert mode has a drawback. For example if you type

This is today's date dd
Date: Wed Mar 18 11:23:09 IST 2015

This prints the date below. But if you hit undo u it deletes the entire text inxluding This is today’s date unless you switched to normal mode first. So good to remember that.

Similar mapping in insert mode

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

Based on some feedback, I learnt that there is a key difference between map and noremap noremap is an option that prevents mapping recursively. Consider these mappings

map a $
map T a
noremap M a

Here typing a will take you to the end of the line. T will do the same. However M will behave as a and let you append from current cursor position. So it is always recommended to use non recursive versions of mappings to not get caught in unexpected recursive maps. So generally user

nnoremap, xnoremap, cnoremap, inoremap, etc.

unless know you know what you are doing.

:map vs noremap

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

I often need to insert logging statements in my code for debugging purposes. The following mapping will help me easily do that, then get my cursor ready to start typing my debug statements.

noremap db ologging.debug("")hi
inoremap db logging.debug("")hi

So hitting

db
will print
logging.debug("|")

with my cursor ready to type between the debug quotes.

One more example

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

Sometimes you have some plugins with your vim setup that already define a ton of mappings. You can use

:map
:noremap

and

:imap
:inoremap

to list all your command and insert mode mappings. Similarly you can list your other mode mappings with corresponding commands.

What keys can I map

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

Ensure you are not overlapping with existing mappings or existing vim commands so that your current functionality does not break. Example mapping my command to dd instead of dd would mess up my delete line functionality. Also ensure you have your key mappings in the mode that you want them in.

Caveats

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

You can find more details about key mapping in vim documentation itself.

:help key-mappings
:help 40.1
:help map-overview

Let me know if you have any comments or suggestions in the comments below and of any cool ways you use custom key mappings. Hope you learnt something new today.

Further Reading

Calling all writers!

We’re hiring. Write for Howchoo

Ashley's profile pictureAshley
Joined in 2015
Ashley's profile picture
Share this guide!
RedditEmailText
Related to this guide:
Vim undo branchesVim undo branches
You probably already know how to use vim’s basic undo and redo features. For a quick refresher, read this short tutorial on how to use vim redo and undo.
Dayne's profile picture DayneView
In these interests: vim
3 Ways to Use Tabs in Vim3 Ways to Use Tabs in Vim
Vim tabs can be a great way to visualize which files you currently have open. Many vim users get bogged down by them and either end up working too hard to use them or give up altogether.
Dayne's profile picture DayneView
In these interests: vim
Vim redo and undoVim redo and undo
Learn how to undo and redo changes using vim. If you are brand new to vim, learn more about the basics in this intro to vim guide.
Dayne's profile picture DayneView
In these interests: vim
Vim undo branchesVim undo branches
You probably already know how to use vim’s basic undo and redo features. For a quick refresher, read this short tutorial on how to use vim redo and undo.
Dayne's profile picture DayneView
In these interests: vim
Dayne's profile pictureViewvim
3 Ways to Use Tabs in Vim3 Ways to Use Tabs in Vim
Vim tabs can be a great way to visualize which files you currently have open. Many vim users get bogged down by them and either end up working too hard to use them or give up altogether.
Dayne's profile picture DayneView
In these interests: vim
Dayne's profile pictureViewvim
Vim redo and undoVim redo and undo
Learn how to undo and redo changes using vim. If you are brand new to vim, learn more about the basics in this intro to vim guide.
Dayne's profile picture DayneView
In these interests: vim
Dayne's profile pictureViewvim
People also read:
Once you learn to think in text objects, you’ll never be the same
Vim is a powerful tool. I often paste raw data into Vim in order to format it in a specific way, and sometimes I need to clean up the file by removing many blank lines.
One of the strengths of Vim is that it’s highly customizable. And while remapping keys is possible, we often want to create shortcuts without changing the default key bindings.
If you find yourself highlighting text in Vim with your mouse to copy and paste it elsewhere, stop. There’s a better way, using the yank command, to copy text into your clipboard on macOS or Windows.
Basic vim commands
Because you’ve accidentally opened Vim and don’t know how to exit
Vim is amazing. Well, Python is doing all the work, but I still like Vim. Learn how to format JSON in Vim like a pro with this short guide! tl;dr Paste your json, and run this in vim normal mode. :%!
Tabs are evil. This guide will show you how to convert tabs to spaces in Vim.
Need to change the case of characters to all caps or all lowercase? This is easily done using Vim. This guide will show you how to change the case of characters in Vim.
Trailing whitespace can be a real pain – especially when diffing changes between two versions of a file.
Once you learn to think in text objects, you’ll never be the same
Vim is a powerful tool. I often paste raw data into Vim in order to format it in a specific way, and sometimes I need to clean up the file by removing many blank lines.
One of the strengths of Vim is that it’s highly customizable. And while remapping keys is possible, we often want to create shortcuts without changing the default key bindings.
If you find yourself highlighting text in Vim with your mouse to copy and paste it elsewhere, stop. There’s a better way, using the yank command, to copy text into your clipboard on macOS or Windows.
Basic vim commands
Because you’ve accidentally opened Vim and don’t know how to exit
Vim Text Objects: Using Vim Text Objects
How to Delete Blank Lines in Vim
How to Change Your Leader Key in Vim
Vim: How to Copy to Your System Clipboard
Basic vim commands
Basic vim commandsBasic Vim Commands
Vim is amazing. Well, Python is doing all the work, but I still like Vim. Learn how to format JSON in Vim like a pro with this short guide! tl;dr Paste your json, and run this in vim normal mode. :%!
Tabs are evil. This guide will show you how to convert tabs to spaces in Vim.
Need to change the case of characters to all caps or all lowercase? This is easily done using Vim. This guide will show you how to change the case of characters in Vim.
Trailing whitespace can be a real pain – especially when diffing changes between two versions of a file.
How to Format JSON in Vim
Vim: Convert Tabs to Spaces
How to Change or Switch the Case of Characters in Vim
Ack Search, Open Files in Vim
Vim: How to Remove Trailing Whitespace on Save in Vim
Posted in these interests:
vimvim
vim
PRIMARY
codecode
Code is poetry — one line at a time.
vimvim
vim
PRIMARY
PRIMARY
Explore
codecode
Code is poetry — one line at a time.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Share this guide!
Related to this guide:
How to enable the dashboard in OS X El CapitanHow to enable the dashboard in OS X El Capitan
As someone who uses OS X dashboard widgets often, I was dismayed to find out that Apple has hidden it by default. Thankfully, it’s easy to reenable the dashboard in El Capitan. Here’s how to do it.
Zach's profile picture ZachView
In these interests: osxmacelcapitan
How to delete an application on Mac OS XHow to delete an application on Mac OS X
There are a few different methods for deleting an application based on how you installed it.
Tyler's profile picture TylerView
In these interests: osxmac
How to switch between the windows of an application on OS XHow to switch between the windows of an application on OS X
Many applications use multiple windows, and there is a handy keyboard shortcut to help you switch quickly between them.
Tyler's profile picture TylerView
In these interests: osxmac
People also read:
There are plenty of websites that will automatically convert a video into a gif. Some of these sites even have a few options to customize the gif you create.
This guide shows you how to change the HipChat notification sound in both Mac and Windows. Presently, the notification sound cannot be changed through either native application.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
This guide was written for OS X 10.9. For an updated version of this guide click here. There are plenty of reasons you will want to encrypt files on your personal computer.
This shortcut takes your cursor directly to the searchbox after opening Mail.app. This works in all current versions of OSX.
This short guide shows you how to disable the additional Mac menubars/toolbars and docks that were added in OS X Mavericks.
Posted in these interests:
osxosx
osx
PRIMARY
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Share this guide!
Related to this guide:
How to enable the dashboard in OS X El CapitanHow to enable the dashboard in OS X El Capitan
As someone who uses OS X dashboard widgets often, I was dismayed to find out that Apple has hidden it by default. Thankfully, it’s easy to reenable the dashboard in El Capitan. Here’s how to do it.
Zach's profile picture ZachView
In these interests: osxmacelcapitan
How to delete an application on Mac OS XHow to delete an application on Mac OS X
There are a few different methods for deleting an application based on how you installed it.
Tyler's profile picture TylerView
In these interests: osxmac
How to switch between the windows of an application on OS XHow to switch between the windows of an application on OS X
Many applications use multiple windows, and there is a handy keyboard shortcut to help you switch quickly between them.
Tyler's profile picture TylerView
In these interests: osxmac
People also read:
There are plenty of websites that will automatically convert a video into a gif. Some of these sites even have a few options to customize the gif you create.
This guide shows you how to change the HipChat notification sound in both Mac and Windows. Presently, the notification sound cannot be changed through either native application.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
This guide was written for OS X 10.9. For an updated version of this guide click here. There are plenty of reasons you will want to encrypt files on your personal computer.
This shortcut takes your cursor directly to the searchbox after opening Mail.app. This works in all current versions of OSX.
This short guide shows you how to disable the additional Mac menubars/toolbars and docks that were added in OS X Mavericks.
Posted in these interests:
osxosx
osx
PRIMARY
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Share this guide!
Related to this guide:
How to enable the dashboard in OS X El CapitanHow to enable the dashboard in OS X El Capitan
As someone who uses OS X dashboard widgets often, I was dismayed to find out that Apple has hidden it by default. Thankfully, it’s easy to reenable the dashboard in El Capitan. Here’s how to do it.
Zach's profile picture ZachView
In these interests: osxmacelcapitan
How to delete an application on Mac OS XHow to delete an application on Mac OS X
There are a few different methods for deleting an application based on how you installed it.
Tyler's profile picture TylerView
In these interests: osxmac
How to switch between the windows of an application on OS XHow to switch between the windows of an application on OS X
Many applications use multiple windows, and there is a handy keyboard shortcut to help you switch quickly between them.
Tyler's profile picture TylerView
In these interests: osxmac
People also read:
There are plenty of websites that will automatically convert a video into a gif. Some of these sites even have a few options to customize the gif you create.
This guide shows you how to change the HipChat notification sound in both Mac and Windows. Presently, the notification sound cannot be changed through either native application.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
Flushing your dns is a very useful troubleshooting step and is necessary for some network changes to take effect.
This guide was written for OS X 10.9. For an updated version of this guide click here. There are plenty of reasons you will want to encrypt files on your personal computer.
This shortcut takes your cursor directly to the searchbox after opening Mail.app. This works in all current versions of OSX.
This short guide shows you how to disable the additional Mac menubars/toolbars and docks that were added in OS X Mavericks.
Posted in these interests:
osxosx
osx
PRIMARY
OS X is a series of Unix-based operating systems developed by Apple, Inc. The first public beta, called Kodiak, appeared in 2000.
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

How to Display macOS Notifications from the Command Line

Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020

In this guide, we’re going to use AppleScript and a tool called osascript to display macOS notifications. AppleScript is a scripting language created by Apple that allows us to automate control of Mac applications, and osascript is a tool that allows us to execute AppleScript from the command line.

With these tools, we can easily display macOS notifications from the command line or from within shell scripts.

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides

How to Display macOS Notifications from the Command Line

macapple
Tyler Tyler (285)
Total time: 5 minutes 
Updated: July 22nd, 2020
Tyler
2
 

Posted in these interests:

mac
PRIMARY
81 guides
apple
51 guides
mac
PRIMARY
81 guides
apple
51 guides
PRIMARY
Calling all writers!

We’re hiring. Write for Howchoo

2
 
In these interests
mac
PRIMARY
81 guides
apple
51 guides
mac
PRIMARY
81 guides
apple
51 guides
PRIMARY

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Text-only notification

The display command can be run like this:

display notification "test notification!"

But if we want to execute this from the command line, we need to use osascript with the -e flag.

osascript -e 'display notification "test notification!"'

Notification with a title

osascript -e 'display notification "test notification!" with title "This is the title"'

Run any of these examples from the Terminal application (or your favorite terminal emulator), and you’ll see the notifications appear!

Use the “display” AppleScript command

Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Tyler's profile picture
Share this guide!
RedditEmailText
Related to this guide:
How to Convert HEIC files to JPGHow to Convert HEIC files to JPG
Now when you airdrop photos from your phone, you can easily convert them to JPGs.
Michael's profile picture MichaelView
In these interests: osxmac
Screen Shot of Image Properties ScreenScreen Shot of Image Properties Screen
Before you lose years converting those PNG files to JPGs.
Michael's profile picture MichaelView
In these interests: macosmac
Reset Network Settings MacOSReset Network Settings MacOS
Trouble with Wi-Fi? Don’t forget to try this.
Ash's profile picture AshView
In these interests: networkingapplemac
How to Convert HEIC files to JPGHow to Convert HEIC files to JPG
Now when you airdrop photos from your phone, you can easily convert them to JPGs.
Michael's profile picture MichaelView
In these interests: osxmac
Michael's profile pictureViewosxmac
Screen Shot of Image Properties ScreenScreen Shot of Image Properties Screen
Before you lose years converting those PNG files to JPGs.
Michael's profile picture MichaelView
In these interests: macosmac
Michael's profile pictureViewmacosmac
Reset Network Settings MacOSReset Network Settings MacOS
Trouble with Wi-Fi? Don’t forget to try this.
Ash's profile picture AshView
In these interests: networkingapplemac
Ash's profile pictureViewnetworkingapplemac
People also read:
Force your Mac to use the Ethernet/wired connection when it’s connected.
MacBook
Strange Mac issue? One of these will probably fix it.
An Apple keyboard on a desk showing fn and control keys
If you’re used to CTRL being the bottom left key, this guide will help you.
“I wish my MacOS apps could tap me on the shoulder until I answer.” – No one ever
MacBook Pro Keyboard showing Control Strip
The Touch Bar is a neat addition to the MacBook Pro. For me, however, it’s kind of annoying and I just want my normal Control Strip back rather than application-specific options.
Tired of Zoom’s security issues? Get rid of it.
Connect your favorite Bluetooth device.
Uninstall software from macOS.
You clean up your desk, why not your desktop?
Every time I go to empty my Mac’s trash, I have to click yet another dialog box to confirm. I find this a tad annoying, but thankfully this is an option we can control.
Force your Mac to use the Ethernet/wired connection when it’s connected.
MacBook
Strange Mac issue? One of these will probably fix it.
An Apple keyboard on a desk showing fn and control keys
If you’re used to CTRL being the bottom left key, this guide will help you.
“I wish my MacOS apps could tap me on the shoulder until I answer.” – No one ever
How to Prioritize Ethernet Over Wi-Fi in macOS
MacBook
MacBookHow to Reset Your Mac’s PRAM, SMC, and NVRAM (and Why)
Mac keyboard symbols
Mac keyboard symbolsMac Keyboard Symbol Reference Guide
An Apple keyboard on a desk showing fn and control keys
An Apple keyboard on a desk showing fn and control keysHow to Remap the fn (Function) key to ctrl (Control) on Mac
How to Disable the Mac Dock Icon Bouncing Behavior
MacBook Pro Keyboard showing Control Strip
The Touch Bar is a neat addition to the MacBook Pro. For me, however, it’s kind of annoying and I just want my normal Control Strip back rather than application-specific options.
Tired of Zoom’s security issues? Get rid of it.
Connect your favorite Bluetooth device.
Uninstall software from macOS.
You clean up your desk, why not your desktop?
Every time I go to empty my Mac’s trash, I have to click yet another dialog box to confirm. I find this a tad annoying, but thankfully this is an option we can control.
MacBook Pro Keyboard showing Control Strip
MacBook Pro Keyboard showing Control StripHow to Disable the MacBook Pro Touch Bar
How to Fully Uninstall Zoom from your Mac
How to Turn on Bluetooth in macOS
Uninstall software from macOS.
Uninstall software from macOS.How to Uninstall Software on Mac
How to Disable the Mac Empty Trash Warning (macOS and OS X)
Posted in these interests:
macmac
mac
PRIMARY
appleapple
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.
macmac
mac
PRIMARY
PRIMARY
Explore
appleapple
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Share this guide!
Related to this guide:
Reset Network Settings MacOSReset Network Settings MacOS
Trouble with Wi-Fi? Don’t forget to try this.
Ash's profile picture AshView
In these interests: networkingapplemac
How to Prioritize Ethernet Over Wi-Fi in macOSHow to Prioritize Ethernet Over Wi-Fi in macOS
Force your Mac to use the Ethernet/wired connection when it’s connected.
Zach's profile picture ZachView
In these interests: networkingmacosmac
MacBookMacBook
Strange Mac issue? One of these will probably fix it.
Zach's profile picture ZachView
In these interests: applemac
People also read:
An Apple keyboard on a desk showing fn and control keys
If you’re used to CTRL being the bottom left key, this guide will help you.
“I wish my MacOS apps could tap me on the shoulder until I answer.” – No one ever
MacBook Pro Keyboard showing Control Strip
The Touch Bar is a neat addition to the MacBook Pro. For me, however, it’s kind of annoying and I just want my normal Control Strip back rather than application-specific options.
Tired of Zoom’s security issues? Get rid of it.
Connect your favorite Bluetooth device.
Uninstall software from macOS.
You clean up your desk, why not your desktop?
Posted in these interests:
macmac
mac
PRIMARY
appleapple
Apple Computers is an American computer and consumer electronics company founded by Steve Jobs and Steve Wozniak.
Discuss this guide:
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!
We’re hiring!
Are you a passionate writer or editor? We want to hear from you!

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

How to Manage Cookies in JavaScript

Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020

At some point you’ll want to read, set, and remove cookies using JavaScript. This is actually way more complicated than it should be so I’ll provide a few example functions and refer you to a solid jQuery plugin.

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');

How to Manage Cookies in JavaScript

Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020

At some point you’ll want to read, set, and remove cookies using JavaScript. This is actually way more complicated than it should be so I’ll provide a few example functions and refer you to a solid jQuery plugin.

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');
Jump to step

How to Manage Cookies in JavaScript

Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020

At some point you’ll want to read, set, and remove cookies using JavaScript. This is actually way more complicated than it should be so I’ll provide a few example functions and refer you to a solid jQuery plugin.

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');

How to Manage Cookies in JavaScript

Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020

At some point you’ll want to read, set, and remove cookies using JavaScript. This is actually way more complicated than it should be so I’ll provide a few example functions and refer you to a solid jQuery plugin.

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides

How to Manage Cookies in JavaScript

javascriptcode
Jeremy Jeremy (10)
Total time: 5 minutes 
Updated: July 22nd, 2020
Jeremy
1
 

Posted in these interests:

javascript
PRIMARY
27 guides
code
68 guides
javascript
PRIMARY
27 guides
code
68 guides
PRIMARY
Jump to step
Calling all writers!

We’re hiring. Write for Howchoo

1
 
In these interests
javascript
PRIMARY
27 guides
code
68 guides
javascript
PRIMARY
27 guides
code
68 guides
PRIMARY
Jump to step

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

First you should understand what the cookie is and how it’s set. A cookie is a string that is stored on the user’s computer to allow data to persist throughout the user’s session. Cookies are often set by HTTP response headers, but they can also be set directly in the browser using JavaScript. To read the entire cookie string you can access document.cookie.

document.cookie
What you’ll likely see is a long string of semi-colon delineated key/value pairs.
ps=31;_ssd3=P0-1415818163-1436218393727;favorite_animal=goat;_gaa=23.00334.....

document.cookie

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

You can manually set a cookie by setting document.cookie equal to the desired cookie using this format:

document.cookie = "name=tyler;expires=Thu, 03 Sep 2015 05:33:44 GMT";
This can be a little cumbersome, so the function below should make things easier.
function setCookie(name, value, exdays) { var d, expires; exdays = exdays || 1; d = new Date(); d.setTime(d.getTime() + (exdays2460601000)); expires = "expires=" + d.toUTCString(); document.cookie = name + "=" + value + "; " + expires; }
To set a cookie that lasts for one year, you could use:
setCookie('name', 'Batman', 365);

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).

To read a cookie you can simply access document.cookie.

console.log(document.cookie);
If you’re searching for a specific value you can use the following function.
function getCookie(name) { var cookie, c; cookies = document.cookie.split(';'); for (var i=0; i < cookies.length; i++) { c = cookies[i].split('='); if (c[0] == name) { return c[1]; } } return ""; }
This function uses JavaScript’s string split method to split the cookie string by semi-colons. Then it loops through the result array of strings and splits them again by “=” producing the cookie key/value pair. Then it simply tests the cookie key (c[0]) against the name of the cookie you are trying to read. If it matches it returns the value (c[1]).
Mentioned here
How to Split a String into an Array in JavaScript

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

To delete a cookie, you simply need to expire it. So deleting a cookie is basically setting the cookie with an expiration in the past. Using our setCookie function:

setCookie('name', '', -1);

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');

If you’re using jQuery, you might as well use this cookie plugin. It allows easy management of cookies.

// read $.cookie('name'); // => "Batman" // set $.cookie('name', 'Iron Man'); // delete $.removeCookie('name');
Calling all writers!

We’re hiring. Write for Howchoo

Jeremy's profile pictureJeremy
Joined in 2015
Programmer, brogrammer, whoagrammer.
Jeremy's profile picture
Share this guide!
RedditEmailText
Related to this guide:
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
How to Pretty Print JSON in Chrome Developer ConsoleHow to Pretty Print JSON in Chrome Developer Console
In these interests: codejavascriptwebdev
Zach's profile pictureViewcodejavascriptwebdev
Remove Elements From an Array in JavaScriptRemove Elements From an Array in JavaScript
When working with arrays in JavaScript, we often need to remove elements.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
Enumerable Properties in JavaScriptEnumerable Properties in JavaScript
Enumerable properties are properties whose internal enumerable flag set to true.
Tyler's profile picture TylerView
In these interests: codejavascript
Tyler's profile pictureViewcodejavascript
People also read:
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
Learn how to split a string into an array.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API.
This guide demonstrates multiple ways to iterate over a JavaScript object’s properties and values.
There are two very similar statements in JavaScript: for…in and for…of. And while they can be easily confused, they’re actually quite different.
My journey trying to find the one loop operator to rule them all
As a JavaScript developer, you’ll often need to construct URLs and query string parameters. One sensible way to construct query string parameters is to use a one layer object with key value pairs.
Writing tests is an important part of software development process. Unit tests form a core part of testing process where each functional block is tested as an independent unit.
Learn Multiple Ways to Iterate Over JavaScript Object Properties and Values
The Difference Between “for…in” and “for…of” in JavaScript
JavaScript for loops
How to Turn an Object into Query String Parameters in JavaScript
Unit Testing in JavaScript – Mocha, Chai and Sinon – a Beginner’s Guide
Making a deep copy of an object in JavaScript is fairly challenging. Fortunately, there are a few ways to accomplish this without much code.
Learn how to split a string into an array.
This guide will teach you how to concatenate, or join, all elements of an array into a single string.
Learn how to merge two arrays together in JavaScript.
Tabbed browsing has become the standard so modern browsers have provided a way for developers to determine if a tab has focus. This uses the HTML 5 Page Visibility API.
How to Copy an Object in JavaScript
How to Split a String into an Array in JavaScript
How to Join All Elements of an Array in JavaScript
How to Merge Two Arrays in JavaScript
Determine if a Tab has Focus in JavaScript
Posted in these interests:
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
codecode
Code is poetry — one line at a time.
javascriptjavascript
javascript
PRIMARY
Array(16).join(“wat” – 1) + ” Batman!”;
PRIMARY
Explore
codecode
Code is poetry — one line at a time.
Explore
Discuss this guide:
We’re hiring!
Are you a passionate writer? We want to hear from you!
We’re hiring!
Are you a passionate writer? We want to hear from you!
View openings

Want to support Howchoo? When you buy a tool or material through one of our Amazon links, we earn a small commission as an Amazon Associate.

Donate
Total time: 10 minutes 
Updated: July 22nd, 2020
python
PRIMARY
67 guides
code
68 guides
programming
8 guides
Calling all writers!

We’re hiring. Write for Howchoo

python
PRIMARY
67 guides
code
68 guides
programming
8 guides
Calling all writers!

We’re hiring. Write for Howchoo

Tyler's profile pictureTyler
Joined in 2015
Software Engineer and creator of howchoo.
Get the latest edition of Python in just minutes.
Ash's profile picture AshView
In these interests: codewindowspython
Run Python scripts in command prompt without typing the whole path.
Ash's profile picture AshView
In these interests: windowscodepython
You can run any Python script in a command-line interface.
Ash's profile picture AshView
In these interests: python
Got a Python question? We’ve probably answered it here.
Not sure what version of Python you’re running? Time to find out!
Python is a very popular programming language for data visualization.
In Python, comprehensions are a useful construct that allows us to create new sequences in a very concise way.
Slack has become one of the most important tools for communication in many companies, mine included.
If you’re familiar with Python’s keyword-only arguments, then you’ve probably wondered why the same constraint doesn’t exist for positional arguments. This changes with Python 3.
Specify a parallel filesystem cache for compiled bytecode
Learn how to use formatted string literals in Python
While this requirement may seem rare, learning how to nest defaultdicts properly in Python can be extremely powerful and save you from bloated and confusing initialization code.
python
PRIMARY
Python is howchoo’s favorite programming language. We believe python promotes the most organized and performant codebase possible. We also love Django so, naturally, we love Python.
Code is poetry — one line at a time.