{"id":26,"date":"2019-03-27T18:09:48","date_gmt":"2019-03-27T17:09:48","guid":{"rendered":"https:\/\/esoftwar.es\/blog\/?p=26"},"modified":"2019-04-04T10:23:56","modified_gmt":"2019-04-04T09:23:56","slug":"comprender-los-metodos-call-apply-y-bind-en-ecmascript","status":"publish","type":"post","link":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/","title":{"rendered":"Comprender los m\u00e9todos call,  apply y bind en ECMAScript"},"content":{"rendered":"<p>Vamos a intentar comprender los m\u00e9todos <strong>call()<\/strong> ,\u00a0 <strong>apply() <\/strong>y<strong> bind()<\/strong> de JavaScript.<\/p>\n<p>Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son <strong>call()<\/strong> ,\u00a0 <strong>apply() <\/strong>y<strong> bind()<\/strong>. Ambos m\u00e9todos nos permiten llamar a una funci\u00f3n que no pertenece al \u00e1mbito de un objeto y hacer que se ejecute como si perteneciese al \u00e1mbito del objeto.<\/p>\n<p>\u00bfQu\u00e9?, \u00bfC\u00f3mo?, \u00bf\u00c1mbito del objeto?<br \/>\n<!--more--><br \/>\n\u00a1Vaya lio!<\/p>\n<p>Tranquilos que paso a explicarlo con m\u00e1s detalle la funcionalidad correcta que se hace de estos m\u00e9todos. Y como nada mejor para explicarlo que con c\u00f3digo JavaScript.<\/p>\n<p>Bien, como hab\u00edamos dicho que ambos m\u00e9todos nos permiten llamar a una funci\u00f3n fuera del \u00e1mbito de un objeto pues creemos una funci\u00f3n en el scope o \u00e1mbito de Windows.<\/p>\n<p>Antes de nada, para los que no tengan muy claro qu\u00e9 es un objeto en JavaScript ser\u00eda esto:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">var myObj = {\r\n  person: 'Lector',\r\n  description: 'para entender los m\u00e9todos call(), apply() y bind() de JavaScript'\r\n}  \/\/ Object\r\n<\/pre>\n<p>Bien pasemos a crear la funci\u00f3n:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">\/\/ Funci\u00f3n que sirve para saludar.\r\nfunction saludar(saludo){\r\n  console.log(saludo); \/\/ Texto - Reusar saludo\r\n\r\n  var respuesta = [ this.person,'est\u00e1 leyendo c\u00f3digo JavaScript', this.description].join(' ');\r\n\r\n  console.log(respuesta); \r\n}<\/pre>\n<p>Ahora ejecutamos los m\u00e9todos apply y call<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-theme=\"atomic\">\/\/ Pasamos a ejecutar los m\u00e9todos\r\n\r\n\/* \r\n  M\u00e9todo apply()\r\n\r\n  Se usa un array para pasarles los par\u00e1metros\r\n\r\n  Ejemplo: myFuncion.apply(myObjeto, ['param1','param2','param3', 'paramN']);\r\n\r\n*\/\r\nsaludar.apply(myObj, ['Reusar saludo']); \r\n\r\n\/* \r\n  M\u00e9todo call()\r\n\r\n  Se usa un String para pasarles los par\u00e1metros\r\n\r\n  Ejemplo: myFuncion.apply(myObjeto, 'param1','param2','param3', 'paramN');\r\n\r\n*\/\r\nsaludar.call(myObj,'Reusar saludo');<\/pre>\n<p>Y el resultado ser\u00eda algo como esto:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"raw\" data-enlighter-theme=\"atomic\">Reusar saludo\r\nLector est\u00e1 leyendo c\u00f3digo JavaScript para entender los m\u00e9todos call(), apply() y bind() de JavaScript\r\n\r\nReusar saludo\r\nLector est\u00e1 leyendo c\u00f3digo JavaScript para entender los m\u00e9todos call(), apply() y bind() de JavaScript<\/pre>\n<p>Ah, vale ! Voy entendiendo algo.. \u00bfPero este ejemplo no es un poco chorra o de poco uso?<\/p>\n<p>Pues si, vamos a intentar hacerlo con un ejemplo m\u00e1s al uso, ahora que hemos visto c\u00f3mo se comportan los m\u00e9todos <strong>apply<\/strong> y <strong>call<\/strong> de javascript.<\/p>\n<p>Bien antes de nada hay que tener muy en cuenta la palabra clave <strong><span style=\"color: #ff0000;\">this <\/span><\/strong><span style=\"color: #000000;\">que hemos usado en nuestro objeto ya que hace referencia a la parte de la memoria donde esta nuestro <span style=\"color: #ff0000;\"><strong>myObj<\/strong><\/span><br \/>\n<\/span><\/p>\n<p>La palabra <strong><span style=\"color: #ff0000;\">this<\/span><\/strong> tienen mucha relaci\u00f3n con el manejo de la referencia en memoria de los distintos contextos que usemos y los m\u00e9todos <strong>apply<\/strong>, <strong>call<\/strong> y <strong>bind<\/strong> est\u00e1n muy relacionados con el uso del <strong><span style=\"color: #ff0000;\">this<\/span><\/strong> sobre el contexto o objeto que usamos, es decir, se usan en conjunto para manejar la posici\u00f3n en memoria de objetos o funciones.<\/p>\n<p>Bla bla bla, mucho texto pero aun no he visto la funcionalidad de todo esto.<\/p>\n<p>\u00a1 Ok, vamos a ver un ejemplo !<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">\/\/ Mi Objeto\r\nconst person = {\r\n  name: 'Darth',\r\n  lastname: 'Vader',\r\n  fullname: function() {\r\n    return this.name + ' ' + this.lastname;\r\n  }\r\n}<\/pre>\n<p>Ahora creamos la funci\u00f3n a usar:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">\/\/ Creamos nuestra function\r\nconst imprimeSaludo = function(textSaludo, textFinal) {\r\n  console.log(textSaludo, this.fullname(), 'wellcome to', textFinal);\r\n}\r\n\r\n\/* \r\n * Observa aqu\u00ed que 'this.fullname()' tiene el mismo nombre que\r\n * usamos en el objeto 'person'\r\n *\/<\/pre>\n<p>Si ahora intentamos ejecutar la funci\u00f3n <span style=\"color: #0000ff;\">imprimeSaludo<\/span>(<span style=\"color: #339966;\">&#8216;Hi&#8217;<\/span>,<span style=\"color: #339966;\">&#8216;Dark side of the galaxy&#8217;<\/span>); nos arrojar\u00e1 un error de tipo <code class=\"markup--code markup--p-code\">this.fullname() is not a function.<\/code><\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">\/\/ Error - this.fullname() is not a function. ;P\r\nimprimeSaludo('Hi','Dark side of the galaxy');<\/pre>\n<p>Esto es debido a que <strong><span style=\"color: #ff0000;\">this<\/span><\/strong> dentro de la funci\u00f3n <strong><span style=\"color: #3366ff;\">imprimeSaludo<\/span><\/strong> apunta al contexto global y no al contexto de nuestro objeto.<\/p>\n<p>Vale entiendo pero \u00bfc\u00f3mo lo soluciono?<\/p>\n<p>Vamos a ver la soluci\u00f3n a este error com\u00fan en el desarrollo javascript<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-theme=\"atomic\">\/\/ Soluci\u00f3n\r\nconst imprimeSaludoEnContexto = imprimeSaludo.bind(person);\r\n\r\nimprimeSaludoEnContexto('Hi', 'Dark side of the galaxy');<\/pre>\n<p>Ahora deber\u00edamos de ver correctamente el saludo:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"atomic\">Hi Darth Vader wellcome to Dark side of the galaxy<\/pre>\n<p>Y para usar los m\u00e9todos <strong>call<\/strong> y <strong>apply<\/strong> para este mismo ejemplo se usar\u00eda de esta forma:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\" data-enlighter-theme=\"atomic\">\/\/ Usando los m\u00e9todos call() y apply()\r\nimprimeSaludo.call(person, 'Hi', 'Dark side of the galaxy');\r\nimprimeSaludo.apply(person, ['Hi', 'Dark side of the galaxy']);\r\n\r\n\/*\r\n * Aqu\u00ed debemos de observar que los par\u00e1metros pasados\r\n * al objeto 'person' tienen que ser pasado de distinta\r\n * forma para un m\u00e9todo o para el otro.\r\n * En el m\u00e9todo call() se usa un n\u00famero de String separados por coma\r\n * En el m\u00e9todo apply() se usa un array de String\r\n *\/<\/pre>\n<h3>Conclusi\u00f3n<\/h3>\n<p>Hemos visto como el <strong><span style=\"color: #ff0000;\">this<\/span><\/strong> dentro de una funci\u00f3n apunta al <code class=\"markup--code markup--p-code\">objeto global<\/code> y no a la propia funci\u00f3n como objeto. Para solucionar esto JavaScript tiene estos tres m\u00e9todos que toda function tiene implicitamente y resuelve los contexto a los que apuntan los objetos en JavaScript.<\/p>\n<div id=\"s3gt_translate_tooltip_mini\" class=\"s3gt_translate_tooltip_mini_box\" style=\"background: initial !important; border: initial !important; border-radius: initial !important; border-spacing: initial !important; border-collapse: initial !important; direction: ltr !important; flex-direction: initial !important; font-weight: initial !important; height: initial !important; letter-spacing: initial !important; min-width: initial !important; max-width: initial !important; min-height: initial !important; max-height: initial !important; margin: auto !important; outline: initial !important; padding: initial !important; position: absolute; table-layout: initial !important; text-align: initial !important; text-shadow: initial !important; width: initial !important; word-break: initial !important; word-spacing: initial !important; overflow-wrap: initial !important; box-sizing: initial !important; display: initial !important; color: inherit !important; font-size: 13px !important; font-family: X-LocaleSpecific, sans-serif, Tahoma, Helvetica !important; line-height: 13px !important; vertical-align: top !important; white-space: inherit !important; left: 565px; top: 2752px; opacity: 0.85;\">\n<div id=\"s3gt_translate_tooltip_mini_logo\" class=\"s3gt_translate_tooltip_mini\" title=\"Traducir texto seleccionado\"><\/div>\n<div id=\"s3gt_translate_tooltip_mini_sound\" class=\"s3gt_translate_tooltip_mini\" title=\"Escuchar\"><\/div>\n<div id=\"s3gt_translate_tooltip_mini_copy\" class=\"s3gt_translate_tooltip_mini\" title=\"Copiar texto al Portapapeles\"><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Vamos a intentar comprender los m\u00e9todos call() ,\u00a0 apply() y bind() de JavaScript. Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son call() ,\u00a0 apply() y bind(). Ambos m\u00e9todos nos permiten llamar a una funci\u00f3n que no pertenece al \u00e1mbito de un objeto y hacer que se ejecute [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":103,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"full-width-content","footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"post-26","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-javascript","8":"entry"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.9 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Comprender los m\u00e9todos call, apply y bind en ECMAScript - Aprendiendo lenguajes por c\u00f3digo<\/title>\n<meta name=\"description\" content=\"Vamos a enteder los m\u00e9todos call, apply y bind de JavaScript. Para qu\u00e9 se usan y por qu\u00e9 debemos de conocerlos. Desde ECMAScript 5 se introdujo los m\u00e9todos.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\" \/>\n<meta property=\"og:locale\" content=\"es_ES\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Comprender los m\u00e9todos call, apply y bind en ECMAScript\" \/>\n<meta property=\"og:description\" content=\"Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son call() , apply() y bind().\" \/>\n<meta property=\"og:url\" content=\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\" \/>\n<meta property=\"og:site_name\" content=\"Aprendiendo lenguajes por c\u00f3digo\" \/>\n<meta property=\"article:published_time\" content=\"2019-03-27T17:09:48+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2019-04-04T09:23:56+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\" \/>\n\t<meta property=\"og:image:width\" content=\"850\" \/>\n\t<meta property=\"og:image:height\" content=\"300\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Francisco Pay\u00e1n\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:title\" content=\"Comprender los m\u00e9todos call, apply y bind en ECMAScript\" \/>\n<meta name=\"twitter:description\" content=\"Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son call() , apply() y bind().\" \/>\n<meta name=\"twitter:image\" content=\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\" \/>\n<meta name=\"twitter:label1\" content=\"Escrito por\" \/>\n\t<meta name=\"twitter:data1\" content=\"Francisco Pay\u00e1n\" \/>\n\t<meta name=\"twitter:label2\" content=\"Tiempo de lectura\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutos\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\"},\"author\":{\"name\":\"Francisco Pay\u00e1n\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/987708a8a221d06730da8fe3a552aebf\"},\"headline\":\"Comprender los m\u00e9todos call, apply y bind en ECMAScript\",\"datePublished\":\"2019-03-27T17:09:48+00:00\",\"dateModified\":\"2019-04-04T09:23:56+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\"},\"wordCount\":502,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\",\"articleSection\":[\"JavaScript\"],\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\",\"url\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\",\"name\":\"Comprender los m\u00e9todos call, apply y bind en ECMAScript - Aprendiendo lenguajes por c\u00f3digo\",\"isPartOf\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\",\"datePublished\":\"2019-03-27T17:09:48+00:00\",\"dateModified\":\"2019-04-04T09:23:56+00:00\",\"description\":\"Vamos a enteder los m\u00e9todos call, apply y bind de JavaScript. Para qu\u00e9 se usan y por qu\u00e9 debemos de conocerlos. Desde ECMAScript 5 se introdujo los m\u00e9todos.\",\"breadcrumb\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#breadcrumb\"},\"inLanguage\":\"es\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage\",\"url\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\",\"contentUrl\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png\",\"width\":850,\"height\":300,\"caption\":\"javascript method call apply and bind\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/esoftwar.es\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Comprender los m\u00e9todos call, apply y bind en ECMAScript\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#website\",\"url\":\"https:\/\/esoftwar.es\/blog\/\",\"name\":\"Aprendiendo lenguajes por c\u00f3digo\",\"description\":\"Blog para geek y otras hierbas.\",\"publisher\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/esoftwar.es\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"es\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#organization\",\"name\":\"esoftwar.es\",\"url\":\"https:\/\/esoftwar.es\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/Logo550.png\",\"contentUrl\":\"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/Logo550.png\",\"width\":550,\"height\":550,\"caption\":\"esoftwar.es\"},\"image\":{\"@id\":\"https:\/\/esoftwar.es\/blog\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/987708a8a221d06730da8fe3a552aebf\",\"name\":\"Francisco Pay\u00e1n\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"es\",\"@id\":\"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/2ea17ea73a0207c077cefb69f8fcf7c5c420e02371e882b906295cde73c5fd50?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/2ea17ea73a0207c077cefb69f8fcf7c5c420e02371e882b906295cde73c5fd50?s=96&d=mm&r=g\",\"caption\":\"Francisco Pay\u00e1n\"},\"description\":\"Desarrollador Backend, Frontend y Mobile. Autodidacta apasionado del c\u00f3digo fuente. Mis metas son aprender y desarrollar c\u00f3digo en el d\u00eda a d\u00eda. Me gusta la m\u00fasica, el deporte al aire libre y tener amigos\/as.\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Comprender los m\u00e9todos call, apply y bind en ECMAScript - Aprendiendo lenguajes por c\u00f3digo","description":"Vamos a enteder los m\u00e9todos call, apply y bind de JavaScript. Para qu\u00e9 se usan y por qu\u00e9 debemos de conocerlos. Desde ECMAScript 5 se introdujo los m\u00e9todos.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/","og_locale":"es_ES","og_type":"article","og_title":"Comprender los m\u00e9todos call, apply y bind en ECMAScript","og_description":"Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son call() , apply() y bind().","og_url":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/","og_site_name":"Aprendiendo lenguajes por c\u00f3digo","article_published_time":"2019-03-27T17:09:48+00:00","article_modified_time":"2019-04-04T09:23:56+00:00","og_image":[{"width":850,"height":300,"url":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","type":"image\/png"}],"author":"Francisco Pay\u00e1n","twitter_card":"summary_large_image","twitter_title":"Comprender los m\u00e9todos call, apply y bind en ECMAScript","twitter_description":"Todas las funciones en la especificaci\u00f3n ECMAScript tienen estos m\u00e9todos intr\u00ednsecos o predeterminados estos m\u00e9todos son call() , apply() y bind().","twitter_image":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","twitter_misc":{"Escrito por":"Francisco Pay\u00e1n","Tiempo de lectura":"4 minutos"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#article","isPartOf":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/"},"author":{"name":"Francisco Pay\u00e1n","@id":"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/987708a8a221d06730da8fe3a552aebf"},"headline":"Comprender los m\u00e9todos call, apply y bind en ECMAScript","datePublished":"2019-03-27T17:09:48+00:00","dateModified":"2019-04-04T09:23:56+00:00","mainEntityOfPage":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/"},"wordCount":502,"commentCount":0,"publisher":{"@id":"https:\/\/esoftwar.es\/blog\/#organization"},"image":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage"},"thumbnailUrl":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","articleSection":["JavaScript"],"inLanguage":"es","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/","url":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/","name":"Comprender los m\u00e9todos call, apply y bind en ECMAScript - Aprendiendo lenguajes por c\u00f3digo","isPartOf":{"@id":"https:\/\/esoftwar.es\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage"},"image":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage"},"thumbnailUrl":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","datePublished":"2019-03-27T17:09:48+00:00","dateModified":"2019-04-04T09:23:56+00:00","description":"Vamos a enteder los m\u00e9todos call, apply y bind de JavaScript. Para qu\u00e9 se usan y por qu\u00e9 debemos de conocerlos. Desde ECMAScript 5 se introdujo los m\u00e9todos.","breadcrumb":{"@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#breadcrumb"},"inLanguage":"es","potentialAction":[{"@type":"ReadAction","target":["https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/"]}]},{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#primaryimage","url":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","contentUrl":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/js-method-post.png","width":850,"height":300,"caption":"javascript method call apply and bind"},{"@type":"BreadcrumbList","@id":"https:\/\/esoftwar.es\/blog\/comprender-los-metodos-call-apply-y-bind-en-ecmascript\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/esoftwar.es\/blog\/"},{"@type":"ListItem","position":2,"name":"Comprender los m\u00e9todos call, apply y bind en ECMAScript"}]},{"@type":"WebSite","@id":"https:\/\/esoftwar.es\/blog\/#website","url":"https:\/\/esoftwar.es\/blog\/","name":"Aprendiendo lenguajes por c\u00f3digo","description":"Blog para geek y otras hierbas.","publisher":{"@id":"https:\/\/esoftwar.es\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/esoftwar.es\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"es"},{"@type":"Organization","@id":"https:\/\/esoftwar.es\/blog\/#organization","name":"esoftwar.es","url":"https:\/\/esoftwar.es\/blog\/","logo":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/esoftwar.es\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/Logo550.png","contentUrl":"https:\/\/esoftwar.es\/blog\/wp-content\/uploads\/2019\/03\/Logo550.png","width":550,"height":550,"caption":"esoftwar.es"},"image":{"@id":"https:\/\/esoftwar.es\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/987708a8a221d06730da8fe3a552aebf","name":"Francisco Pay\u00e1n","image":{"@type":"ImageObject","inLanguage":"es","@id":"https:\/\/esoftwar.es\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/2ea17ea73a0207c077cefb69f8fcf7c5c420e02371e882b906295cde73c5fd50?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/2ea17ea73a0207c077cefb69f8fcf7c5c420e02371e882b906295cde73c5fd50?s=96&d=mm&r=g","caption":"Francisco Pay\u00e1n"},"description":"Desarrollador Backend, Frontend y Mobile. Autodidacta apasionado del c\u00f3digo fuente. Mis metas son aprender y desarrollar c\u00f3digo en el d\u00eda a d\u00eda. Me gusta la m\u00fasica, el deporte al aire libre y tener amigos\/as."}]}},"_links":{"self":[{"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/posts\/26","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/comments?post=26"}],"version-history":[{"count":31,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions"}],"predecessor-version":[{"id":139,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/posts\/26\/revisions\/139"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/media\/103"}],"wp:attachment":[{"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/media?parent=26"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/categories?post=26"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/esoftwar.es\/blog\/wp-json\/wp\/v2\/tags?post=26"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}