Skip to content

Instantly share code, notes, and snippets.

[JavaScript] - Primitives vs Objects

Primitive, Object

Primitives' values are stored in the call stack

Primitives (string, number, bigint, boolean, undefined, symbol, null)

// this is a primitive so its value are stored in the stack
// Identifier age - Address 001 - Value 30

[JavaScript] - Regular function vs arrow function

Arrow Function

this inside arrow function

const alex = {
  firstName: 'Alex',
  year: 1990,

[JavaScript] Hoisting and Temporal Death Zone (TDZ)

Hoisting, TDZ, Function Hoisting, Variable hoisting

TDZ:

A let or const variable is said to be in a "temporal dead zone" (TDZ) from the start of the block until code execution reaches the line where the variable is declared and initialized.

While inside the TDZ, the variable has not been initialized with a value, and any attempt to access it will result in a ReferenceError. The variable is initialized with a value when execution reaches the line of code where it was declared. If no initial value was specified with the variable declaration, it will be initialized with a value of undefined.

VS Code Tips and Tricks

  • Useful plugins:

    • Important:
      • Gruvbox Theme (jdinhlife)
      • IntelliJ IDEA Keybindings (Keisuke Kato)
      • Prettier - Code formatter (prettier.io)
      • Live Server (Ritwick Dey) or use live-server installed from npm
  • Code Runner (Jun Han)

Github - Check which PR contains a commit

  1. In Android Studio, in the file that need to check for change > Right click > Git > Show History
  2. On the history window, right click on a commit > Open on GitHub
  3. On the opened GitHub page look at the URL and copy the commit hash
https://github.com/your_repo/your_project/commit/commit_hash

copy the commit_hash

Android - Set location for Emulator

SOURCE

  1. Open Google Map, select a location then right click, the top most is Lat-Long info, copy that data.
  2. In your emulator, click More (3 dot icon)
  3. Under Location, paste in the Lat-Long data from above (default location is America).
  4. Send
  5. Restart the emulator (tested and confirmed working with in device restart: Pull down the notification shade > Shutdown > Restart).

How to download Blob Stream

SOURCE, SOURCE

Some video streaming site will hide the download link behind a blob format which will get resolved internally. If you inspect the video player in Chrome you can see something like this:

<video class="jw-video jw-reset" tabindex="-1" disableremoteplayback="" webkit-playsinline="" playsinline="" src="blob:https://play.vstreamplay.xyz/1c36398f-c376-4873-a0ac-7fa07c3968f7"></video>

Force 64 bit ABI Installation

SOURCE

To test 64 bit compatibility, we would need to force 64 bit ABI installation on a 64 bit emulator:

  1. Create an emulator using 64 bit image (x86_64).
  2. Use this command to specify 64 bit ABI:

[Security] [Android]

1. TapJacking attack

When the filterTouchesWhenObscured attribute is set to false, the app will be subject to tapjacking attacks. Tapjacking is an attack where an adversary puts an invisible overlay over the app and requests permissions without the user knowing it.

<Button
        android:id="@+id/buttonLogin"
        android:layout_width="wrap_content"
 android:layout_height="wrap_content"