# JavaScript Math expm1() function ## JavaScript Math expm1() function :

expm1() is defined in Math. It is a static method and you can call it directly like Math.expm1(). It takes one number as the argument and returns e^n - 1, where n is the provided number. That means, its value is equal to Math.exp(n) - 1.

## Example of Math.expm1 :

Let’s consider the below example :

``````console.log(Math.expm1(0));
console.log(Math.expm1(1));
console.log(Math.expm1(Math.E));
console.log(Math.expm1(-10));``````

Run it and it will print the below output :

``````0
1.718281828459045
14.154262241479262
-0.9999546000702375``````

## Math.expm1() and Math.exp() :

Let’s compare Math.expm1 and Math.exp :

``````console.log(`\${Math.expm1(0)} = \${Math.exp(0) - 1}` );
console.log(`\${Math.expm1(1)} = \${Math.exp(1) - 1}` );
console.log(`\${Math.expm1(Math.E)} = \${Math.exp(Math.E) - 1}` );
console.log(`\${Math.expm1(-10)} = \${Math.exp(-10) - 1}` );``````

It will print :

``````0 = 0
1.718281828459045 = 1.718281828459045
14.154262241479262 = 14.154262241479262
-0.9999546000702375 = -0.9999546000702375``````

So, Math.expm1 is equal to Math.exp minus 1 for a number.

## Math.expm1 with different types :

For the below example :

``````console.log(Math.expm1("2"));
console.log(Math.expm1(2.4));
console.log(Math.expm1("2.4"));
console.log(Math.expm1(null));
console.log(Math.expm1(undefined));
console.log(Math.expm1());
console.log(Math.expm1("s"));``````

It will print :

``````6.38905609893065
10.023176380641601
10.023176380641601
0
NaN
NaN
NaN``````

For null, it returns 0. For other values, it tries to convert to a number. If it converts, it calculates for that value, else returns NaN.

### Where is the color and why codevscolor ?

Long story short, I love paintings and I paint on weekends. We(me and my wife) have one Youtube channel. Below is a video that I did recently. If you love this please do subscribe to support us 😊
{"ft_lang_label":"__label__en","ft_lang_prob":0.5583876,"math_prob":0.98025405,"size":1555,"snap":"2020-45-2020-50","text_gpt3_token_len":496,"char_repetition_ratio":0.2804642,"word_repetition_ratio":0.0,"special_character_ratio":0.44115755,"punctuation_ratio":0.27671233,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9994359,"pos_list":[0,1,2],"im_url_duplicate_count":[null,null,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2020-12-01T07:58:56Z\",\"WARC-Record-ID\":\"<urn:uuid:087f2369-fd27-49d7-b413-a3a814647934>\",\"Content-Length\":\"94235\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:fb016b15-a411-4fd5-a398-12a584a355be>\",\"WARC-Concurrent-To\":\"<urn:uuid:eb4264f3-7a9c-44f8-a0c0-0e04893b8064>\",\"WARC-IP-Address\":\"52.86.133.10\",\"WARC-Target-URI\":\"https://www.codevscolor.com/javascript-math-expm1\",\"WARC-Payload-Digest\":\"sha1:TV2G36NINVSFD5DILJD7OFQXVZLBFDQZ\",\"WARC-Block-Digest\":\"sha1:I7GSODLGHNLWTTUIF4RK5UXOD4FRK5Q4\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2020/CC-MAIN-2020-50/CC-MAIN-2020-50_segments_1606141672314.55_warc_CC-MAIN-20201201074047-20201201104047-00002.warc.gz\"}"}