===
OperatorYou can use the strict equality operator (===
) to check whether a string is empty or not.
The comparsion str === ""
will only return true
if the data type of the value is string and it is not empty, otherwise return false
as demonstrated in the following example:
<script>
if(str === ""){
// string is empty, do something
}
// Some test cases
alert(2 === ""); // Outputs: flase
alert(0 === "") // Outputs: false
alert("" === "") // Outputs: true
alert("Hello World!" === "") // Outputs: false
alert(false === "") // Outputs: false
alert(null === "") // Outputs: false
alert(undefined === "") // Outputs: false
</script>
Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]
React use one Component to many HTML Fragments
A react component is used to return mult...How to use Basic Authorization in PHP curl
When accessing API request over PHP curl...How to split a string into an array in PHP
Use the PHP explode() function...Twitter API OAuth 2.0 Authorization Example
Twitter is one of the most powerful soci...How to move an element into another element using jQuery
Use the jQuery .appendTo() Method You...