Awesome Explanation…. Must Read!
In simple words:
undefined : undefined variable or property
null : property does exist, but holds no value
Let’s see some example for better understanding
console.log(x); // Uncaught ReferenceError: x is not defined
console.log(x); // undefined
alert(typeof x); // undefined
In Step 2, if you see x is defined but still it says its ‘undefined’ when we print it. Because, its defined but it do not have any value in it.
var y = null;
console.log(y); // null
alert(typeof y); // object
null is a type of default value for a variable independent of type of variable.
From the preceding examples, it is clear that undefined and null are two distinct types: undefined is a type itself (undefined) while null is an object.
null is an empty value
undefined is a missing value
null is a special keyword, not an identifier, and thus you cannot treat it as a variable to assign to. But, undefined is an identifier. In both non-strict mode and strict mode, however, you can create a local variable of the name undefined (not recommended).
Default S3 bucket settings do not allow multiple files with same name. When you try to upload file with name which is already present in your S3 bucket, it will overwrite the file without any warning. To avoid overwriting with same name in S3 bucket, can be achieved by Versioning enabled S3 Bucket.
What a Version enabled S3 Bucket benefits?
– Allows you to maintain various files with same name. Here, S3 auto manages to respond to file by selecting the latest version among various files present in S3.
– Can preserve, retrieve, and restore every version of overwritten and deleted objects in your Bucket.
– Can list the version(s) of any particular Amazon S3 Object or you can list all of the versions of all of the objects, which have been overwritten or deleted from an Amazon S3 bucket.
– Can manage destroying of the version files based on custom rules i.e. Life Cycle Management.
How to enable versioning in S3?
1. Choose the S3 bucket you want to enable for versioning.
2. Go to Properties of the bucket
Upload a file in your bucket and then upload same/another file with same name in the bucket. Then you will see versions of the file.
Its Done! Enjoy Coding. 🙂
As APIs are getting more popular day by day either consuming any service in your application or provide any service to others. API documentation become a crucial part of making your API easy to understand and use.
I think documentation is like a recipe through which a person knows “what a person is trying and how to achieve”. Just as chefs rely on well-written recipes to create wonderful dishes, you need to create API documentation that is informative, succinct, and easy to read so other developers can cook up something wonderful using your APIs. 🙂
Remember while creating API Document:
– Should be from user’s perspective
– Be consistent (help yourself too while code)
– Should be in designed manner (not as plain text)
– URIs should be more clear as they are the most obvious thing in your documentation requires users to figure out mapping between your logic and the HTTP client.
– Give some example of usage and combine them with your explanation.
There are various tools/ways to create docs for your existing or new API, below I am going to show you how you can create your own interactive API documentation for your New or existing API using Postman REST Client+Swagger+Api transformer.
Here, are the steps:
Enjoy Coding! 🙂
Tip for using ternary operator
I faced some non-obvious behavior of Ternary Operator while working, actually I was using more than one ternary operator within single statement something like.
echo ( 1 == 1 ) ? ‘pass’ : ( 1 == 2 ) ? ‘fail’ : ‘other’;
// Expected output is ‘pass’ but it will give ‘fail’
This behavior is because ternary expressions are evaluated from left to right. So, lets again look to above example.
To write in more advanced way the above code to get expected output. You need some parentheses around the right hand operand:
echo (1 == 1) ? ‘pass’ : ((2 == 2) ? ‘fail’ : ‘other’);
// Will give output as ‘pass’
I hope this will help.
Enjoy Coding! 🙂