Skip to main content

Featured post

How to Insert line break in Text component in React Native

Hi, I was developing an application in react native.I have to handle lots of text data in this small react native application.I have used  Text component in react native many times. While working on this application,i had a requirement to display some text content with line breaks.I will explain it clearly with an example.I want to display a text as shown below  Welcome Please subscribe my channel I wrote react native code as shown below <View> <Text> Welcome Please subscribe my channel </Text> <View> When i run these lines of code,It will display text as shown below Welcome Please subscribe my channel   - instead of displaying in two lines with line break,it displays in a single line.So i have to find a solution to insert line break in Text component in React Native.After lots of research,i found a clean solution as shown below <View> <Text> Welcome{"\n"} Please subscribe my channel </Text> <View> Here ...

How to check null undefined and empty string in javascript

In this blog post, i am going to explain how to check a given string is empty ,undefined or null in javascript. As a programmer ,we need to use string data types in our daily life.So it is better to have a good understanding of string variables in javascript.



let str1 ='';

if (!str1) {

  console.log("str1 is empty")

} else {

    console.log("str1 is  not empty")

}  // str1 is empty

 

str1= undefined;

if (!str1) {

    console.log("str1 is empty")

} else {

    console.log("str1 is  not empty")

} //str1 is empty



str1= null;

if (!str1) {

    console.log("str1 is empty")

} else {

    console.log("str1 is  not empty")

}  //str1 is empty


str1= 'Technursery';

if (!str1) {

    console.log("str1 is empty")

} else {

    console.log("str1 is  not empty")

}  // str1 is  not empty

  





In the above code,I declared a string variable and assigned the values null, undefined ,empty and Technursery.So based on the condition we get the output.When str1 is null,undefined and empty we got str1 is empty and When str1 is Technursery, we got the output str1 is not empty