<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Piyush Sinha on Medium]]></title>
        <description><![CDATA[Stories by Piyush Sinha on Medium]]></description>
        <link>https://medium.com/@piyushsinha94?source=rss-83ee019bf047------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*lnipnvcIs3WjASCskPoJ4Q.jpeg</url>
            <title>Stories by Piyush Sinha on Medium</title>
            <link>https://medium.com/@piyushsinha94?source=rss-83ee019bf047------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 19:42:50 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@piyushsinha94/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Testing Custom Events With Enzyme (React)]]></title>
            <link>https://medium.com/the-mavenhive-blog/testing-custom-events-with-enzyme-react-ed63d9744f18?source=rss-83ee019bf047------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed63d9744f18</guid>
            <category><![CDATA[jest]]></category>
            <category><![CDATA[enzyme]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Piyush Sinha]]></dc:creator>
            <pubDate>Fri, 26 Apr 2019 09:53:42 GMT</pubDate>
            <atom:updated>2019-04-26T10:23:12.843Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z4G1Q9UuEes_01WTObDJkw.png" /><figcaption>Image taken from this <a href="https://medium.com/codeclan/testing-react-with-jest-and-enzyme-20505fec4675">blog</a></figcaption></figure><p>In this blog we will learn how to test custom events in react. We have a togglable component which can be used on a page to toggle data or a view.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fgiphy.com%2Fembed%2FejyGFl2WUpWuEdUY81%2Ftwitter%2Fiframe&amp;url=https%3A%2F%2Fmedia.giphy.com%2Fmedia%2FejyGFl2WUpWuEdUY81%2Fgiphy.gif&amp;image=https%3A%2F%2Fi.giphy.com%2Fmedia%2FejyGFl2WUpWuEdUY81%2F200.gif&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=giphy" width="435" height="90" frameborder="0" scrolling="no"><a href="https://medium.com/media/e6a51b8d3be84e78d642406479cba749/href">https://medium.com/media/e6a51b8d3be84e78d642406479cba749/href</a></iframe><p>Source Code for the TogglableComponent and the component where it is used.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/50d332ab3ef7fa8034c9373267ef3725/href">https://medium.com/media/50d332ab3ef7fa8034c9373267ef3725/href</a></iframe><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6bc12b9699fbd62f7de0b3e0d94224f7/href">https://medium.com/media/6bc12b9699fbd62f7de0b3e0d94224f7/href</a></iframe><p>Now we want to test the functionality in the component where the <strong>TogglableComponent</strong> is used. In this case, <strong>Home</strong> Component.</p><p>In Enzyme <strong>simulate</strong> function is used to trigger the events on the wrapper.</p><p>For eg. here we simulate click on a &lt;button/&gt; and checking if the state of <strong>TogglableComponent</strong> is disabled.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0922ccee58d126a6968ccbfd3b719384/href">https://medium.com/media/0922ccee58d126a6968ccbfd3b719384/href</a></iframe><p>Now we want to test the functionality in <strong>Home </strong>Component if the toggling work in the way it is intended to</p><p><strong>How to Test Custom Events</strong></p><p><strong>Option 1</strong>: By calling the internal method or an event which is attached to TogglableComponent and also which is passed as props to it.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/71b4fad91e98ccde30cc0f5f6dcc4b1d/href">https://medium.com/media/71b4fad91e98ccde30cc0f5f6dcc4b1d/href</a></iframe><p>Disadvantages with this option are we are not really testing the functionality. We are only testing the internals of the component.<br>So the binding of the function with the element might go untested. Also, it becomes to difficult refactor as implementation is coupled with the testing.</p><p><strong>Option 2</strong>: Can we use Enzyme to trigger custom events? Yes we can</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/e66f92ce8745f2d2c330ebc03439f6c4/href">https://medium.com/media/e66f92ce8745f2d2c330ebc03439f6c4/href</a></iframe><p>To be able to trigger the <strong>toggle </strong>custom event, the prop name should <strong>start with “on”</strong>.<strong> </strong>In above case the custom event is <strong>onToggle</strong> and we simulate <strong>toggle</strong> in tests<strong>. </strong>Similarly<strong> </strong>“onJump”, “onAdd” custom events can be tested.</p><blockquote>Thanks to <a href="https://medium.com/u/ddd4bde32144">Monika M</a> for her help in writing this blog.</blockquote><blockquote>This stackoverflow <a href="https://stackoverflow.com/questions/39767177/using-enzyme-simulate-on-custom-events">question</a> was motivation behind writing this blog</blockquote><blockquote>The issue for testing custom events for shallow rendered children in enzyme is still opened on <a href="https://github.com/airbnb/enzyme/issues/147">https://github.com/airbnb/enzyme/issues/147</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed63d9744f18" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-mavenhive-blog/testing-custom-events-with-enzyme-react-ed63d9744f18">Testing Custom Events With Enzyme (React)</a> was originally published in <a href="https://medium.com/the-mavenhive-blog">The MavenHive Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A comparison between RabbitMQ and Apache Kafka]]></title>
            <link>https://medium.com/the-mavenhive-blog/which-one-to-use-and-when-rabbitmq-vs-apache-kafka-7d5423301b58?source=rss-83ee019bf047------2</link>
            <guid isPermaLink="false">https://medium.com/p/7d5423301b58</guid>
            <category><![CDATA[rabbitmq]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[microservices]]></category>
            <dc:creator><![CDATA[Piyush Sinha]]></dc:creator>
            <pubDate>Mon, 04 Jun 2018 20:27:13 GMT</pubDate>
            <atom:updated>2018-12-24T14:24:50.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*BGZy6Puq8X9AQHkJzB7BLA.jpeg" /><figcaption>Image used from this <a href="https://www.cloudamqp.com/blog/2017-01-09-apachekafka-vs-rabbitmq.html">blog</a> post. <a href="https://www.cloudamqp.com/">RabbitMQ</a> and <a href="https://www.cloudkarafka.com/">Apache Kafka</a> SaaS is provided by CloudAMQP.</figcaption></figure><p>RabbitMQ, Kafka and many other messaging systems are implementations of Publisher-Subscriber Pattern.</p><p>Publish/Subscribe is distributed interaction paradigm well adapted to deployment of scalable and loosely coupled systems. In this post we will understand the functionalities of Pub/Sub System, learn about Kafka and RabbitMQ, draw a comparison between them on different parameters and at last we will go through the best use cases for both systems.</p><h3>Core Functionalities Of Pub/Sub Systems.</h3><p><strong>I</strong>. <strong>Decoupling publishers and subscribers</strong> is the most fundamental functionality of pub/sub systems and can be decomposed into three different dimensions.</p><ol><li><strong>Entity Decoupling</strong>: publishers and consumers do not need to be aware of each other i.e pub/ sub infrastructure terminates the interaction in the middle</li><li><strong>Time Decoupling</strong>: The interacting parties do not need to be actively participating in the interaction, or even stronger, switched on, at the same time.</li><li><strong>Synchronization decoupling</strong>: the interaction between either producer or consumer and the pub/sub infrastructure does not synchronously need to block the producer or consumer execution threads, allowing maximum usage of processor resources at producers and consumers alike.</li></ol><p><strong>II</strong>. <strong>Routing Logic (or Subscription Model)</strong> which decides if and where a packet that is coming from a producer will end up at a consumer. Two types of routing logics are:</p><ol><li><a href="https://github.com/EasyNetQ/EasyNetQ/wiki/Topic-Based-Routing"><strong>Topic Based</strong></a>: Publisher tags the message with a set of topics that can be used very efficiently in filtering operations that decides which message goes to which consumer.</li><li><a href="http://www.javarticles.com/2015/07/apache-camel-content-based-%20routing.html"><strong>Content Based</strong></a>: All data and meta fields of the message can be used in filtering conditions.</li></ol><p>Consumers subscribe to selective events by specifying filters using subscription language. Evaluating these complex filters comes at high processing cost.</p><p>Quality Of Service Guarantees For A Pub/Sub System.</p><ol><li><strong><em>Correctness</em></strong> <strong><em>-&gt;</em></strong> correctness behavior can be defined by three primitives. No-loss, no-duplication, no-disorder.</li><li><strong><em>Availability</em></strong> <strong><em>-&gt;</em></strong> It is the capacity of a system to maximize its uptime.</li><li><strong><em>Scalability</em></strong> <strong><em>-&gt;</em></strong>The concept of scalability refers to the ability of a system to continuously evolve in order to support a growing amount of tasks. Various dimensions are consumer/producer, topics and messages.</li><li><strong><em>Transactions -&gt; </em></strong>In messaging systems, transactions are used to group messages into atomic units: either a complete sequence of messages is sent (received), or none of them is.</li><li><strong><em>Efficiency -&gt; </em></strong>Two common measures of efficiency are the latency (or response time), and the throughput (or bandwidth).<br>* <strong>Latency</strong>. In any transport architecture, latency of a packet/message is . determined by the serial pipeline (i.e., sequence of processing steps) that it passes through.<br>* <strong>Throughput</strong>. Throughput of a transport architecture is the number of packets (or alternatively, bytes) per time unit that can be transported between producers and consumers.</li></ol><p><strong>Important</strong>: Efficiency and Scalability often conflict with other desirable guarantees.</p><p>For eg. highly expressive and selective subscriptions require complex and expensive filtering and routing algorithms, and thus limit scalability.</p><h3><strong>Apache Kafka</strong></h3><p>Kafka was originally built at LinkedIn as its centralized event pipelining platform, replacing a disparate set of point-to-point integration systems<br>Kafka is designed to handle high throughput (billions of messages) .</p><p>In its design, particular attention has been paid to the efficient handling of multiple consumers of the same stream that read at different speeds (e.g., streaming vs batch).</p><p>The resulting system is a scalable publish-subscribe messaging system designed around a <a href="https://engineering.linkedin.com/distributed-systems/log-what-every-software-engineer-should-know-about-real-time-datas-unifying">distributed commit log</a>.</p><h3><strong>RabbitMQ</strong></h3><p>RabbitMQ is primarily known and used as an efficient and scalable implementation of the Advanced Message Queuing Protocol (AMQP).</p><p>What is now known as AMQP originated in 2003 at JPMorgan Chase. From the beginning AMQP was conceived as a co-operative open effort. JPMorgan Chase partnered with Red Hat to create Apache Qpid. Independently, RabbitMQ was developed in Erlang by Rabbit Technologies.</p><p>The design of AMQP has been driven by stringent performance, scalability and reliability requirements from the finance community.</p><h3>Comparison between both the systems on different parameters</h3><ol><li><strong>Time Decoupling: </strong>Both systems can be used to buffer a large batch of messages that needs to be consumed at a later time or at a much lower rate than it is produced.<br><strong><em>RabbitMQ</em></strong> will store the messages in DRAM as long as possible, but once the available DRAM is completely consumed, RabbitMQ will start storing messages on disk without having a copy available in DRAM, which will severely impact performance.<br><strong><em>Kafka</em></strong>, on the other hand, was specifically designed with the various consumption rates requirement in mind and hence is much better positioned to handle a wider scale of time decoupling.</li><li><strong>Routing Logic: <br>RabbitMQ</strong> inherits the routing logic of AMQP and hence can be very sophisticated. Another relevant and useful feature in RabbitMQ is Alternate Exchange which allows clients to handle messages that an exchange was unable to route (i.e. either because there were no bound queues or no matching bindings).<br>With<strong> Kafka</strong>, the choice is more limited, it supports a basic form of topic-based routing. More specifically, the producer controls which partition it publishes messages to.</li><li><strong>Delievery Guarantees:</strong>RabbitMQ and Kafka differ in their notion of at least once semantics. Since individual packets from a batch can fail, recovery from failures can have impact on the order of packets. Depending on the application, order might be important, so it makes sense to split this up in<strong><br></strong>* <strong>at least once <em>without order conservation</em></strong>: <strong>Kafka</strong> cannot preserve order when sending to multiple partitions.<br>* <strong>at least once <em>with order conservation</em></strong>: <strong>RabbitMQ</strong> sorts messages when writing them to queue structures, meaning that lost messages can be correctly delivered in order without the need to resend the full batch that lost 1 or more messages.<br><strong>Note</strong>: The only way to guarantee that a message is not lost is by using transactions which are unnecessarily heavyweight and decrease throughput.</li><li><strong>ORDERING GUARANTEES: <br>RabbitMQ</strong> will conserve order for flows using a single AMQP channel. It also reorders retransmitted packets inside its queue logic so that a consumer does not need to resequence buffers. This implies that if a load-balancer would be used in front of RabbitMQ (e.g. to reach the scalability of what can be accomplished inside Kafka with partitions), packets that leave the load-balancer on different channels will have no ordering relation anymore.<br><strong>Kafka</strong> will conserve order only inside a partition. Furthermore, within a partition, Kafka guarantees that a batch of messages either all pass or all fail together. However, o conserve inter-batch order, the producer needs to guarantee that at most 1 produce request is outstanding, which will impact maximum performance.</li><li><strong>AVAILABILITY:<br>RabbitMQ</strong> Clusters can be configured to replicate all the exchange and binding information. However, it will not automatically create mirrored queues (RabbitMQ’s terminology for replicated queues) and will require explicit setting during queue creation.<br>For <strong>Kafka</strong>, availability requires running the system with a suitably high replication factor.</li><li><strong>TRANSACTIONS:<br></strong>AMQP guarantees atomicity only when transactions involve a single queue.<strong> RabbitMQ</strong> provides no atomicity guarantees even in case of transactions involving just a single queue,.Take e.g. a producer publishing a batch. If any of the messages fails, the producer gets the chance to republish these messages, and RabbitMQ will insert them in the queue in order. After which the publisher is notified that the failing messages did make it and can consider the transaction complete.<br><strong>Kafka</strong> extended support for transactions recently for applications which exhibit a “read-process-write” pattern where the reads and writes are from and to asynchronous data streams such as Kafka topics.</li><li><strong>MULTICAST:<br>RabbitMQ</strong> supports multicast by providing a dedicated queue per individual consumer. As a result, the only impact on the system is that there is an increased number of bindings to support these individual queues.<br>In <strong>Kafka</strong>, only one copy of messages within a topic is maintained in the brokers (in non-replicated settings); however, the multicast logic is handled completely at the consumer side.</li><li><strong>DYNAMIC SCALING<br></strong>For <strong>RabbitMQ</strong>, adding additional nodes to running clusters or removing a node from a cluster is well supported. Adding nodes in a RabbitMQ cluster is transparent for consumers<br>Adding nodes to a <strong>Kafka</strong> cluster is not transparent for consumers, since there needs to be a mapping from partitions to consumers in a consumer group.</li><li><strong>LATENCY RESULTS<br></strong>In case of<strong> RabbitMQ</strong>, up to medium level of load, the latency for both at most once and at least once modes is below 10 ms.<br>In case of <strong>Kafka</strong>, on the other hand, if it can read from OS cache, its latency for at most once mode is below 10 ms, and about twice as large for the at least once mode. However, when it needs to read from disk, its latency can grow by up to an order of magnitude to around 100 ms.</li><li><strong>THROUGHPUT<br>RabbitMQ</strong> is mainly constrained by routing complexity (up till frame sizes of a few 1000 bytes, at which time packet copying becomes non-negligible).<br>Finally, the error rate level in case of<strong> Kafka</strong> is not as low as that of RabbitMQ. Two potential causes for these variations are: (i) Kafka relies on OS level caching of disk access, which is a complex hidden subsystem that cannot be accurately modeled or even controlled and is shared across everything that runs on the machine (ii) Kafka runs on the JVM, which has much more variability than an Erlang VM due to unsophisticated locking mechanisms and the garbage collection process.</li></ol><h3>Best Suit Cases For Kafka</h3><p><strong>Pub/Sub Messaging</strong>. Kafka can be a good match for the pub/sub use cases that exhibit the following properties: (i) if the routing logic is simple, so that a Kafka “topic” concept can handle the requirements, (ii) if throughput per topic is beyond what RabbitMQ can handle (e.g. event firehose).</p><p><strong>Scalable Ingestion System</strong>. Many of the leading Big Data processing platforms enable high throughput processing of data once it has been loaded into the system. However, in many cases, loading of the data into such platforms is the main bottleneck. Kafka offers a scalable solution for such scenarios and it has already been integrated into many of such platforms including Apache Spark and Apache Flink.</p><p><strong>Data-Layer Infrastructure</strong>. Due to its durability and efficient client multicast, Kafka can serve as an underlying data infrastructure that connects various batch and streaming services and applications within an enterprise.</p><p><strong>Capturing Change Feeds</strong>. Change feeds are sequences of update events that capture all the changes applied on an initial state (e.g. a table in database, or a particular row within that table). Traditionally, change feeds have been used internally by DBMSs to synchronize replicas. More recently, however, some of the modern data stores have exposed their change feeds externally, so they can be used to synchronize state in distributed environments. Kafka’s log-centric design, makes it an excellent backend for an application built in this style.</p><p><strong>Stream Processing</strong>. Starting in Kafka version 0.10.0.0, a light-weight stream processing library called Kafka Streams is available in Apache Kafka to perform stateful and fault-tolerant data processing. Furthermore, Apache Samza, an open-source stream processing platform is based on Kafka.</p><h3>Best Suit Cases For RabbitMQ</h3><p><strong>Pub/Sub Messaging</strong>. Since this is exactly why RabbitMQ was created, it will satisfy most of the requirements. This is even more so in an edge/core message routing scenario where brokers are running in a particular interconnect topology.</p><p><strong>Request-Response Messaging</strong>. RabbitMQ offers a lot of support for RPC style communication by means of the correlation ID and direct reply-to feature, which allows RPC clients to receive replies directly from their RPC server, without going through a dedicated reply queue that needs to be set up</p><p><strong>Operational Metrics Tracking</strong>. RabbitMQ would be a good choice for realtime processing, based on the complex filtering the broker could provide.</p><p><strong>Underlying Layer for IoT Applications Platform</strong>. RabbitMQ can be used to connect individual operator nodes in a datafow graph, regardless of where the operators are instantiated.</p><h3><strong>References:</strong></h3><ol><li><a href="https://arxiv.org/abs/1709.00333"><em>Kafka versus RabbitMQ: A comparative study.</em></a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7d5423301b58" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-mavenhive-blog/which-one-to-use-and-when-rabbitmq-vs-apache-kafka-7d5423301b58">A comparison between RabbitMQ and Apache Kafka</a> was originally published in <a href="https://medium.com/the-mavenhive-blog">The MavenHive Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Primitives vs Objects in Javascript]]></title>
            <link>https://medium.com/the-mavenhive-blog/primitives-vs-objects-in-javascript-1bd9fc0b8fcd?source=rss-83ee019bf047------2</link>
            <guid isPermaLink="false">https://medium.com/p/1bd9fc0b8fcd</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Piyush Sinha]]></dc:creator>
            <pubDate>Thu, 31 May 2018 08:12:21 GMT</pubDate>
            <atom:updated>2019-02-04T19:12:22.688Z</atom:updated>
            <content:encoded><![CDATA[<p>Values in JavaScript are of two types: Primitives &amp; Objects. Yeah you read it correctly, not everything in JavaScript is an Object.</p><p>What are primitives?<br><strong>The following values are primitives</strong><br>* Strings: &quot;abc&quot;<br>* Numbers: 1, 2, 3.57 (All numbers are floating point)<br>* Boolean: true or false<br>* null<br>* undefined</p><p><strong>Everything else is an object<br>*</strong>Created by literals. Literals produce objects that can be created via a constructor. We should use literals<br> -&gt;[] is samethe as new Array() <br> -&gt;{} is same as new Object() <br> -&gt;function() {} is same as new Function() <br>* Dates: new Date(“2011–12–24”) <br>* Wrappers for primitives: Boolean, Number, String.</p><p>Lets understand how primitives and objects differ by understanding their nature.</p><ol><li><strong>Objects are mutable.</strong></li></ol><pre>&gt; let obj = {};<br>&gt; obj.foo = &quot;123&quot;; //write<br>&quot;123&quot;<br>&gt; obj.foo;    //read<br>&quot;123&quot;</pre><p><strong>Primitives are immutable</strong>. Any property you add will be forgotten immediately.</p><pre>&gt; let str = &quot;abc&quot;;<br>&gt; str.foo = 123;  // write - ignored<br>123<br>&gt; str.foo  // read<br>undefined</pre><p>2. <strong>Objects have unique identities and are compared <em>by reference</em></strong>.Every object you create is different. Two objects will be only equal if they have same identity. It does not matter if they have same content or not. The fact can be determined by === operator.</p><pre>&gt; {} === {}<br>false<br>&gt; let obj = {};<br>&gt; obj === obj<br>true</pre><p><strong>Primitives are compared <em>by value</em>, they don’t have individual identities. </strong>For primitives if there values are equal they are considered equals.</p><pre>&gt; &quot;foo&quot; === &quot;foo&quot;<br>true</pre><h3>Primitive Values and their Wrappers</h3><p><strong><em>Please avoid wrapper types as much as possible.</em><br></strong>The three primitive types string, number and boolean have corresponding types whose instances are objects: String, Number, Boolean. They are sometimes called <em>wrapper types</em> and converting between primitive and wrapper is simple:</p><ul><li>Primitive to wrapper: new String(“abc”)</li><li>Wrapper to primitive: new String(“abc”).valueOf()</li></ul><p>Primitive Values such as “abc” are fundamentally different than wrapper instances new String(“abc”) . We will notice that in examples below.</p><pre>&gt; typeof &quot;abc&quot;<br>&#39;string&#39;<br>&gt; typeof new String(&quot;abc&quot;)<br>&#39;object&#39;</pre><pre>&gt; &quot;abc&quot; instance of String<br>false<br>&gt; new String(&quot;abc&quot;) instance of String<br>true</pre><pre>&gt; &quot;abc&quot; === new String(&quot;abc&quot;)<br>false</pre><h3>Primitive Values have no methods of their own</h3><p>Primitives don’t have their own methods and they borrow them from wrappers</p><pre>&gt; &quot;abc&quot;.charAt === String.prototype.charAt<br>true</pre><p>There are two ways borrowing is done:</p><ol><li>Convert the primitive to a wrapper (Old Way).</li><li>Transparently use the method from wrappers prototype</li></ol><pre>// Methods in Object.prototype are available to all primitives<br>Object.prototype.getType = function() {<br>    return typeof this;<br>};<br>Object.prototype.getTypeStrict = function() {<br>    &quot;use strict&quot;;<br>    return typeof this;<br>};<br>console.log(&quot;&quot;.getType()); // object<br>console.log(&quot;&quot;.getTypeStrict()); // string</pre><p>References:<br><em>Thanks to </em><a href="http://2ality.com/"><em>Dr. Axel Rauschmayer</em></a><em> for his wonderful posts about Javascript world.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1bd9fc0b8fcd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-mavenhive-blog/primitives-vs-objects-in-javascript-1bd9fc0b8fcd">Primitives vs Objects in Javascript</a> was originally published in <a href="https://medium.com/the-mavenhive-blog">The MavenHive Blog</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>