--- lang: ja-jp breaks: true --- # TypeScript で null undefined empty を否定した場合の動作 2021-05-15 ```typescript= 'use strict'; if (!null) { console.log("not null."); } if (null != true) { console.log("null is not true."); } if (!"") { console.log("not emply."); } // ↓compile error. //if ("" != true) //{ // console.log("emply is not true."); //} if (!undefined) { console.log("not undefined."); } if (undefined != true) { console.log("undefined is not true."); } console.log("exit."); ``` ```shell= $ ts-node null_test.ts not null. null is not true. not emply. not undefined. undefined is not true. exit. ``` ###### tags: `TypeScript` `null` `undefined` `empty` `ts-node`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up