Cek Undefined, Null, dan Empty String di Javascript
- Categories:
- javascript
Dalam Javascript pengecekan terhadap suatu variabel apakah sudah dideklarasi (misal menggunakan var
, let
, atau const
) dapat menggunakan operator typeof
. Contoh:
Sedangkan untuk pengecekan suatu variabel yang telah dideklarasikan apakah bernilai undefined
, null
, atau blank / empty string dapat menggunakan:
Dalam kode diatas, myVariableToo
akan bernilai true
jika tidak:
null
undefined
NaN
- blank atau empty string (‘’)
- 0
false
- Tags:
- #javascript
Recent Posts
C# DbContext ServiceLifeTime
my note about C Sharp ServiceLifeTime
PostgreSQL Index Usage Monitoring
Having too many unused or underused indexes on a table can slow down write and update operations in your PostgreSQL database, making it crucial to regularly identify and manage them for optimal performance.
KAK Labs Newsletter #6 - Staying Safe From Pegasus Spyware
Newsletter #6 - Pegasus, Ruby, PostgreSQL and networkQuality tool
Material Design - Paragraph Spacing
According to Google's Material Design, keep paragraph spacing in the range between .75x and 1.25x of the type size.
Amazon SDK for C# - S3 File Download Methods
Comparison between `TransferUtility.DownloadAsync`, `DownloadSingleFileAsync`, and `GetObjectAsync`.